mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Update the configure script to detect pread/pwrite and update os_unix.c to
use those routines if they are available. FossilOrigin-Name: 2cffb9e50bed77d1079603f5b4a71b7559de7294
This commit is contained in:
@@ -71,6 +71,20 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Use pread() and pwrite() if they are available */
|
||||
#if defined(HAVE_PREAD64) && defined(HAVE_PWRITE64)
|
||||
# undef USE_PREAD
|
||||
# undef USE_PWRITE
|
||||
# define USE_PREAD64 1
|
||||
# define USE_PWRITE64 1
|
||||
#elif defined(HAVE_PREAD) && defined(HAVE_PWRITE)
|
||||
# undef USE_PREAD
|
||||
# undef USE_PWRITE
|
||||
# define USE_PREAD64 1
|
||||
# define USE_PWRITE64 1
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
** standard include files.
|
||||
*/
|
||||
@@ -200,6 +214,9 @@ struct unixFile {
|
||||
const char *zPath; /* Name of the file */
|
||||
unixShm *pShm; /* Shared memory segment information */
|
||||
int szChunk; /* Configured by FCNTL_CHUNK_SIZE */
|
||||
#if !defined(USE_PREAD) && !defined(USE_PREAD64)
|
||||
off64_t iOfst; /* Current offset */
|
||||
#endif
|
||||
#if SQLITE_MAX_MMAP_SIZE>0
|
||||
int nFetchOut; /* Number of outstanding xFetch refs */
|
||||
sqlite3_int64 mmapSize; /* Usable size of mapping at pMapRegion */
|
||||
@@ -3097,9 +3114,6 @@ static int nfsUnlock(sqlite3_file *id, int eFileLock){
|
||||
static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
|
||||
int got;
|
||||
int prior = 0;
|
||||
#if (!defined(USE_PREAD) && !defined(USE_PREAD64))
|
||||
i64 newOffset;
|
||||
#endif
|
||||
TIMER_START;
|
||||
assert( cnt==(cnt&0x1ffff) );
|
||||
assert( id->h>2 );
|
||||
@@ -3111,13 +3125,15 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
|
||||
got = osPread64(id->h, pBuf, cnt, offset);
|
||||
SimulateIOError( got = -1 );
|
||||
#else
|
||||
newOffset = lseek(id->h, offset, SEEK_SET);
|
||||
SimulateIOError( newOffset = -1 );
|
||||
if( newOffset<0 ){
|
||||
storeLastErrno((unixFile*)id, errno);
|
||||
return -1;
|
||||
}
|
||||
got = osRead(id->h, pBuf, cnt);
|
||||
if( offset!=id->iOfst ){
|
||||
id->iOfst = lseek(id->h, offset, SEEK_SET);
|
||||
SimulateIOError( id->iOfst = -1 );
|
||||
if( id->iOfst<0 ){
|
||||
storeLastErrno((unixFile*)id, errno);
|
||||
return -1;
|
||||
}
|
||||
got = osRead(id->h, pBuf, cnt);
|
||||
if( got>=0 ) id->iOfst += got;
|
||||
#endif
|
||||
if( got==cnt ) break;
|
||||
if( got<0 ){
|
||||
@@ -3223,6 +3239,7 @@ static int seekAndWriteFd(
|
||||
do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
|
||||
#else
|
||||
do{
|
||||
if( iOff!=fd
|
||||
i64 iSeek = lseek(fd, iOff, SEEK_SET);
|
||||
SimulateIOError( iSeek = -1 );
|
||||
if( iSeek<0 ){
|
||||
|
||||
Reference in New Issue
Block a user