// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT.

//go:build (darwin && amd64) || (darwin && arm64) || (freebsd && amd64) || (freebsd && arm64) || (linux && amd64) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) || (windows && (amd64 || arm64))

package sqlite3

import (
	"unsafe"

	"modernc.org/libc"
)

// C documentation
//
//	/*
//	** The first argument is a file-handle open on a temporary file. The file
//	** is guaranteed to be nByte bytes or smaller in size. This function
//	** attempts to extend the file to nByte bytes in size and to ensure that
//	** the VFS has memory mapped it.
//	**
//	** Whether or not the file does end up memory mapped of course depends on
//	** the specific VFS implementation.
//	*/
func _vdbeSorterExtendFile(tls *libc.TLS, db uintptr, pFd uintptr, _nByte Ti64) {
	bp := tls.Alloc(32)
	defer tls.Free(32)
	*(*Ti64)(unsafe.Pointer(bp)) = _nByte
	var _ /* chunksize at bp+16 */ int32
	var _ /* p at bp+8 */ uintptr
	if **(**Ti64)(__ccgo_up(bp)) <= int64((*Tsqlite3)(unsafe.Pointer(db)).FnMaxSorterMmap) && (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pFd)).FpMethods)).FiVersion >= int32(3) {
		**(**uintptr)(__ccgo_up(bp + 8)) = uintptr(0)
		**(**int32)(__ccgo_up(bp + 16)) = libc.Int32FromInt32(4) * libc.Int32FromInt32(1024)
		_sqlite3OsFileControlHint(tls, pFd, int32(SQLITE_FCNTL_CHUNK_SIZE), bp+16)
		_sqlite3OsFileControlHint(tls, pFd, int32(SQLITE_FCNTL_SIZE_HINT), bp)
		_sqlite3OsFetch(tls, pFd, 0, int32(**(**Ti64)(__ccgo_up(bp))), bp+8)
		if **(**uintptr)(__ccgo_up(bp + 8)) != 0 {
			_sqlite3OsUnfetch(tls, pFd, 0, **(**uintptr)(__ccgo_up(bp + 8)))
		}
	}
}
