// 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"

	"modernc.org/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)<<libc.Int32FromInt32(8))
			if rc != int32(SQLITE_BUSY) {
				_storeLastErrno(tls, pFile, tErrno)
			}
		}
		return rc
	}
	/* got it, set the type and return ok */
	(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = libc.Uint8FromInt32(eFileLock)
	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.
//	**
//	** When the locking level reaches NO_LOCK, delete the lock file.
//	*/
func _dotlockUnlock(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
	/* no-op if possible */
	if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) == eFileLock {
		return SQLITE_OK
	}
	/* To downgrade to shared, simply update our internal notion of the
	 ** lock state.  No need to mess with the file on disk.
	 */
	if eFileLock == int32(SHARED_LOCK) {
		(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK)
		return SQLITE_OK
	}
	/* To fully unlock the database, delete the lock file */
	rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(19)].FpCurrent})))(tls, zLockFile)
	if rc < 0 {
		tErrno = **(**int32)(__ccgo_up(libc.X__errno_location(tls)))
		if tErrno == int32(ENOENT) {
			rc = SQLITE_OK
		} else {
			rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(8)<<libc.Int32FromInt32(8)
			_storeLastErrno(tls, pFile, tErrno)
		}
		return rc
	}
	(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(NO_LOCK)
	return SQLITE_OK
}

func _pthreadMutexEnd(tls *libc.TLS) (r int32) {
	return SQLITE_OK
}

// C documentation
//
//	/*
//	** 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 other kind of mutex
//	** more than once, the behavior is undefined.
//	*/
func _pthreadMutexEnter(tls *libc.TLS, p uintptr) {
	/* Use the built-in recursive mutexes if they are available.
	 */
	libc.Xpthread_mutex_lock(tls, p)
}

// C documentation
//
//	/*
//	** This routine deallocates a previously
//	** allocated mutex.  SQLite is careful to deallocate every
//	** mutex that it allocates.
//	*/
func _pthreadMutexFree(tls *libc.TLS, p uintptr) {
	libc.Xpthread_mutex_destroy(tls, p)
	Xsqlite3_free(tls, p)
}

// C documentation
//
//	/*
//	** Initialize and deinitialize the mutex subsystem.
//	*/
func _pthreadMutexInit(tls *libc.TLS) (r int32) {
	return SQLITE_OK
}

// 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 or
//	** is not currently allocated.  SQLite will never do either.
//	*/
func _pthreadMutexLeave(tls *libc.TLS, p uintptr) {
	libc.Xpthread_mutex_unlock(tls, p)
}

func _pthreadMutexTry(tls *libc.TLS, p uintptr) (r int32) {
	var rc int32
	_ = rc
	/* Use the built-in recursive mutexes if they are available.
	 */
	if libc.Xpthread_mutex_trylock(tls, p) == 0 {
		rc = SQLITE_OK
	} else {
		rc = int32(SQLITE_BUSY)
	}
	return rc
}

// 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.
 */

/*
** Linux-specific IOCTL magic numbers used for controlling F2FS
 */

// C documentation
//
//	/*
//	** Retry ftruncate() calls that fail due to EINTR
//	**
//	** All calls to ftruncate() within this file should be made through
//	** this wrapper.  On the Android platform, bypassing the logic below
//	** could lead to a corrupt database.
//	*/
func _robust_ftruncate(tls *libc.TLS, h int32, sz Tsqlite3_int64) (r int32) {
	var rc int32
	_ = rc
	for cond := true; cond; cond = rc < 0 && **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(EINTR) {
		rc = (*(*func(*libc.TLS, int32, Toff_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(6)].FpCurrent})))(tls, h, sz)
	}
	return rc
}

var _sMutex1 = Tsqlite3_mutex_methods{}

func _sqlite3DefaultMutex(tls *libc.TLS) (r uintptr) {
	return uintptr(unsafe.Pointer(&_sMutex1))
}

// 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" */

// C documentation
//
//	/*
//	** Try to provide a memory barrier operation, needed for initialization
//	** and also for the implementation of xShmBarrier in the VFS in cases
//	** where SQLite is compiled without mutexes.
//	*/
func _sqlite3MemoryBarrier(tls *libc.TLS) {
}

// C documentation
//
//	/* Get the results of the thread */
func _sqlite3ThreadJoin(tls *libc.TLS, p uintptr, ppOut uintptr) (r int32) {
	var rc, v1 int32
	_, _ = rc, v1
	if p == uintptr(0) {
		return int32(SQLITE_NOMEM)
	}
	if (*TSQLiteThread)(unsafe.Pointer(p)).Fdone != 0 {
		**(**uintptr)(__ccgo_up(ppOut)) = (*TSQLiteThread)(unsafe.Pointer(p)).FpOut
		rc = SQLITE_OK
	} else {
		if libc.Xpthread_join(tls, (*TSQLiteThread)(unsafe.Pointer(p)).Ftid, ppOut) != 0 {
			v1 = int32(SQLITE_ERROR)
		} else {
			v1 = SQLITE_OK
		}
		rc = v1
	}
	Xsqlite3_free(tls, p)
	return rc
}

/******************************** End Unix Pthreads *************************/

/********************************* Win32 Threads ****************************/
/******************************** End Win32 Threads *************************/

/********************************* Single-Threaded **************************/
/****************************** 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 <assert.h> */
/* #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,
**                       <proxy_path> | ":auto:");
**  sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE,
**                       &<proxy_path>);
**
**
** SQL pragmas
**
**  PRAGMA [database.]lock_proxy_file=<proxy_path> | :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 "<tmpdir>/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 ".<databasename>-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)<<libc.Int32FromInt32(8))
			if rc != int32(SQLITE_BUSY) {
				_storeLastErrno(tls, pFile, tErrno)
			}
			goto end_lock
		} else {
			if eFileLock == int32(EXCLUSIVE_LOCK) {
				(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(PENDING_LOCK)
				(*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = uint8(PENDING_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) {
		/* Now get the read-lock */
		(**(**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)<<libc.Int32FromInt32(8))
		}
		/* Drop the temporary PENDING lock */
		(**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte)
		(**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1)
		(**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_UNLCK)
		if _unixFileLock(tls, pFile, bp) != 0 && rc == SQLITE_OK {
			/* This could happen with a network mount */
			tErrno = **(**int32)(__ccgo_up(libc.X__errno_location(tls)))
			rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(8)<<libc.Int32FromInt32(8)
		}
		if rc != 0 {
			if rc != int32(SQLITE_BUSY) {
				_storeLastErrno(tls, pFile, tErrno)
			}
			goto end_lock
		} else {
			(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK)
			(*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock + 1
			(*TunixInodeInfo)(unsafe.Pointer(pInode)).FnShared = int32(1)
		}
	} else {
		if eFileLock == int32(EXCLUSIVE_LOCK) && (*TunixInodeInfo)(unsafe.Pointer(pInode)).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 {
			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)<<libc.Int32FromInt32(8))
					if rc != int32(SQLITE_BUSY) {
						_storeLastErrno(tls, pFile, tErrno)
					}
				}
			}
		}
	}
	if rc == SQLITE_OK {
		(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = libc.Uint8FromInt32(eFileLock)
		(*TunixInodeInfo)(unsafe.Pointer(pInode)).FeFileLock = libc.Uint8FromInt32(eFileLock)
	}
	goto end_lock
end_lock:
	;
	Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer(pInode)).FpLockMutex)
	return rc
}

// 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
	_sqlite3MemoryBarrier(tls) /* compiler-defined memory barrier */
	_unixEnterMutex(tls)       /* Also mutex, for redundancy */
	_unixLeaveMutex(tls)
}

const alloca = 0

const blkcnt64_t = 0

type cpu_set_t = Tcpu_set_t

const creat64 = 0

type f_owner_ex = Tf_owner_ex

const fallocate64 = 0

const fgetpos64 = 0

type file_handle = Tfile_handle

const flock64 = 0

const fopen64 = 0

const fpos64_t = 0

const freopen64 = 0

const fsblkcnt64_t = 0

const fseeko64 = 0

const fsetpos64 = 0

const fsfilcnt64_t = 0

const fstat64 = 0

const fstatat64 = 0

const ftello64 = 0

const ftruncate64 = 0

const ino64_t = 0

type itimerspec = Titimerspec

/*
** 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 linux = 1

const lockf64 = 0

const loff_t = 0

const lseek64 = 0

const lstat64 = 0

const mkostemp64 = 0

const mkostemps64 = 0

const mkstemp64 = 0

const mkstemps64 = 0

const mmap64 = 0

const off64_t = 0

const open64 = 0

const openat64 = 0

const posix_fadvise64 = 0

const posix_fallocate64 = 0

const pread64 = 0

type ptrdiff_t = Tptrdiff_t

/*
** 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 pwrite64 = 0

type sched_param = Tsched_param

type sqlite3_io_methods = Tsqlite3_io_methods

/*
** CAPI3REF: Standard File Control Opcodes
** KEYWORDS: {file control opcodes} {file control opcode}
**
** These integer constants are opcodes for the xFileControl method
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
** interface.
**
** <ul>
** <li>[[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].
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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].
**
** <li>[[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].
**
** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
** The SQLITE_FCNTL_SYNC_OMITTED file-control is no longer used.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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].
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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 <em>not</em> use this file-control.
**
** <li>[[SQLITE_FCNTL_ZIPVFS]]
** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
** VFS should return SQLITE_NOTFOUND for this opcode.
**
** <li>[[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.
**
** <li>[[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].
**
** <li>[[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].
**
** <li>[[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].
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[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.
**
** <li>[[SQLITE_FCNTL_CKSM_FILE]]
** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use internally by the
** [checksum VFS shim] only.
**
** <li>[[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.
**
** <li>[[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.
** </ul>
 */

/* 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 <pthread.h> */

/*
** 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.
 */
