// 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) package sqlite3 import ( "unsafe" "modernc.org/libc" ) // C documentation // // /* // ** This API allows applications to modify the global configuration of // ** the SQLite library at run-time. // ** // ** This routine should only be called when there are no outstanding // ** database connections or memory allocations. This routine is not // ** threadsafe. Failure to heed these warnings can lead to unpredictable // ** behavior. // */ func Xsqlite3_config(tls *libc.TLS, op int32, va uintptr) (r int32) { var ap Tva_list var bOpenUri, rc int32 var mxMmap, szMmap Tsqlite3_int64 var pLogArg, pVal, xLog uintptr _, _, _, _, _, _, _, _ = ap, bOpenUri, mxMmap, pLogArg, pVal, rc, szMmap, xLog rc = SQLITE_OK /* sqlite3_config() normally returns SQLITE_MISUSE if it is invoked while ** the SQLite library is in use. Except, a few selected opcodes ** are allowed. */ if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_sqlite3Config))+340) != 0 { if op < 0 || op > int32(63) || libc.Uint64FromInt32(1)< int64(SQLITE_MAX_MMAP_SIZE) { mxMmap = int64(SQLITE_MAX_MMAP_SIZE) } if szMmap < 0 { szMmap = SQLITE_DEFAULT_MMAP_SIZE } if szMmap > mxMmap { szMmap = mxMmap } _sqlite3Config.FmxMmap = mxMmap _sqlite3Config.FszMmap = szMmap case int32(SQLITE_CONFIG_PMASZ): _sqlite3Config.FszPma = libc.VaUint32(&ap) case int32(SQLITE_CONFIG_STMTJRNL_SPILL): _sqlite3Config.FnStmtSpill = libc.VaInt32(&ap) case int32(SQLITE_CONFIG_MEMDB_MAXSIZE): _sqlite3Config.FmxMemdbSize = libc.VaInt64(&ap) case int32(SQLITE_CONFIG_ROWID_IN_VIEW): pVal = libc.VaUintptr(&ap) **(**int32)(__ccgo_up(pVal)) = 0 default: rc = int32(SQLITE_ERROR) break } _ = ap return rc } // C documentation // // /* The page getter for when memory-mapped I/O is enabled */ func _getPageMMap(tls *libc.TLS, pPager uintptr, pgno TPgno, ppPage uintptr, flags int32) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var bMmapOk, rc int32 var _ /* iFrame at bp+8 */ Tu32 var _ /* pData at bp+16 */ uintptr var _ /* pPg at bp+0 */ uintptr _, _ = bMmapOk, rc rc = SQLITE_OK **(**uintptr)(__ccgo_up(bp)) = uintptr(0) **(**Tu32)(__ccgo_up(bp + 8)) = uint32(0) /* Frame to read from WAL file */ /* It is acceptable to use a read-only (mmap) page for any page except ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY ** flag was specified by the caller. And so long as the db is not a ** temporary or in-memory database. */ bMmapOk = libc.BoolInt32(pgno > uint32(1) && (libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == int32(PAGER_READER) || flags&int32(PAGER_GET_READONLY) != 0)) /* Optimization note: Adding the "pgno<=1" term before "pgno==0" here ** allows the compiler optimizer to reuse the results of the "pgno>1" ** test in the previous statement, and avoid testing pgno==0 in the ** common case where pgno is large. */ if pgno <= uint32(1) && pgno == uint32(0) { return _sqlite3CorruptError(tls, int32(65348)) } if bMmapOk != 0 && (*TPager)(unsafe.Pointer(pPager)).FpWal != uintptr(0) { rc = _sqlite3WalFindFrame(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, pgno, bp+8) if rc != SQLITE_OK { **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) return rc } } if bMmapOk != 0 && **(**Tu32)(__ccgo_up(bp + 8)) == uint32(0) { **(**uintptr)(__ccgo_up(bp + 16)) = uintptr(0) rc = _sqlite3OsFetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1))*(*TPager)(unsafe.Pointer(pPager)).FpageSize, int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), bp+16) if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(bp + 16)) != 0 { if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) > int32(PAGER_READER) || (*TPager)(unsafe.Pointer(pPager)).FtempFile != 0 { **(**uintptr)(__ccgo_up(bp)) = _sqlite3PagerLookup(tls, pPager, pgno) } if **(**uintptr)(__ccgo_up(bp)) == uintptr(0) { rc = _pagerAcquireMapPage(tls, pPager, pgno, **(**uintptr)(__ccgo_up(bp + 16)), bp) } else { _sqlite3OsUnfetch(tls, (*TPager)(unsafe.Pointer(pPager)).Ffd, libc.Int64FromUint32(pgno-libc.Uint32FromInt32(1))*(*TPager)(unsafe.Pointer(pPager)).FpageSize, **(**uintptr)(__ccgo_up(bp + 16))) } if **(**uintptr)(__ccgo_up(bp)) != 0 { **(**uintptr)(__ccgo_up(ppPage)) = **(**uintptr)(__ccgo_up(bp)) return SQLITE_OK } } if rc != SQLITE_OK { **(**uintptr)(__ccgo_up(ppPage)) = uintptr(0) return rc } } return _getPageNormal(tls, pPager, pgno, ppPage, flags) } // C documentation // // /* // ** If pFd->sectorSize is non-zero when this function is called, it is a // ** no-op. Otherwise, the values of pFd->sectorSize and // ** pFd->deviceCharacteristics are set according to the file-system // ** characteristics. // ** // ** There are two versions of this function. One for QNX and one for all // ** other systems. // */ func _setDeviceCharacteristics(tls *libc.TLS, pFd uintptr) { if (*TunixFile)(unsafe.Pointer(pFd)).FsectorSize == 0 { /* Set the POWERSAFE_OVERWRITE flag if requested. */ if libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFd)).FctrlFlags)&int32(UNIXFILE_PSOW) != 0 { **(**int32)(__ccgo_up(pFd + 116)) |= int32(SQLITE_IOCAP_POWERSAFE_OVERWRITE) } **(**int32)(__ccgo_up(pFd + 116)) |= int32(SQLITE_IOCAP_SUBPAGE_READ) (*TunixFile)(unsafe.Pointer(pFd)).FsectorSize = int32(SQLITE_DEFAULT_SECTOR_SIZE) } } // C documentation // // /* // ** If it is currently memory mapped, unmap file pFd. // */ func _unixUnmapfile(tls *libc.TLS, pFd uintptr) { if (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion != 0 { (*(*func(*libc.TLS, uintptr, Tsize_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(23)].FpCurrent})))(tls, (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion, libc.Uint64FromInt64((*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeActual)) (*TunixFile)(unsafe.Pointer(pFd)).FpMapRegion = uintptr(0) (*TunixFile)(unsafe.Pointer(pFd)).FmmapSize = 0 (*TunixFile)(unsafe.Pointer(pFd)).FmmapSizeActual = 0 } }