// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT. //go:build (freebsd && arm64) || (linux && arm64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x) package sqlite3 import ( "unsafe" "modernc.org/libc" ) // C documentation // // /* // ** This function is called to obtain a shared lock on the database file. // ** It is illegal to call sqlite3PagerGet() until after this function // ** has been successfully called. If a shared-lock is already held when // ** this function is called, it is a no-op. // ** // ** The following operations are also performed by this function. // ** // ** 1) If the pager is currently in PAGER_OPEN state (no lock held // ** on the database file), then an attempt is made to obtain a // ** SHARED lock on the database file. Immediately after obtaining // ** the SHARED lock, the file-system is checked for a hot-journal, // ** which is played back if present. Following any hot-journal // ** rollback, the contents of the cache are validated by checking // ** the 'change-counter' field of the database file header and // ** discarded if they are found to be invalid. // ** // ** 2) If the pager is running in exclusive-mode, and there are currently // ** no outstanding references to any pages, and is in the error state, // ** then an attempt is made to clear the error state by discarding // ** the contents of the page cache and rolling back any open journal // ** file. // ** // ** If everything is successful, SQLITE_OK is returned. If an IO error // ** occurs while locking the database, checking for a hot-journal file or // ** rolling back a journal file, the IO error code is returned. // */ func _sqlite3PagerSharedLock(tls *libc.TLS, pPager uintptr) (r int32) { bp := tls.Alloc(32) defer tls.Free(32) var f, rc int32 var pVfs uintptr var _ /* bExists at bp+4 */ int32 var _ /* bHotJournal at bp+0 */ int32 var _ /* dbFileVers at bp+12 */ [16]uint8 var _ /* fout at bp+8 */ int32 _, _, _ = f, pVfs, rc rc = SQLITE_OK /* Return code */ /* This routine is only called from b-tree and only when there are no ** outstanding pages. This implies that the pager state should either ** be OPEN or READER. READER is only possible if the pager is or was in ** exclusive access mode. */ if !((*TPager)(unsafe.Pointer(pPager)).FpWal != libc.UintptrFromInt32(0)) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeState) == PAGER_OPEN { **(**int32)(__ccgo_up(bp)) = int32(1) /* True if there exists a hot journal-file */ rc = _pager_wait_on_lock(tls, pPager, int32(SHARED_LOCK)) if rc != SQLITE_OK { goto failed } /* If a journal file exists, and there is no RESERVED lock on the ** database file, then it either needs to be played back or deleted. */ if libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FeLock) <= int32(SHARED_LOCK) { rc = _hasHotJournal(tls, pPager, bp) } if rc != SQLITE_OK { goto failed } if **(**int32)(__ccgo_up(bp)) != 0 { if (*TPager)(unsafe.Pointer(pPager)).FreadOnly != 0 { rc = libc.Int32FromInt32(SQLITE_READONLY) | libc.Int32FromInt32(3)<