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

	"modernc.org/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 <stdarg.h> */

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