Thursday, September 30, 2004, 10:34:50 AM, DRH wrote:

> The problem reported by ticket #924 appears to be mingw brain damage,
> not a bug in SQLite.  Can somebody who uses a recent version of
> mingw (I'm still using a version from 3 or 4 years ago - a version
> that works) please suggest a reasonable workaround.

>    http://www.sqlite.org/cvstrac/tktview?tn=924

Below is some background on the issue.

Summary:

SQLite uses Standard C Library off_t for the size of a file offset.

SQLite on Windows uses the Win32 API for file access, not the
Standard C Library. The Win32 API provides for 64 bit file offsets, so
we take full advantage of that.

MinGW (Win32 API) has off_t as 32 bits for backward binary
Standard C Library compatibility. Recent MinGW runtimes also have
off64_t.

[I sent this earlier to DRH only...]

MinGW has, in <sys/types.h>

typedef long off_t;
typedef long long off64_t;

SQLite uses off_t in several places (see below) and it should be 64
bits on Windows (where we don't use the C runtime for I/O; we use
Win32 API functions).

We have hacked around this for a while with a nested conditional in
os_win.h -- but it is ugly and now failing. It is ugly because it is
breaking the C runtime API. It is now failing because...

Newer MinGW runtimes have added 64 bit i/o support, and so more
headers include <sys/types> to get these off_t type-definitions.

io.h:20:#include <sys/types.h>  /* To get time_t.  */
process.h:18:#include <sys/types.h>
stdio.h:396:#include <sys/types.h>
sys\param.h:12:#include <sys/types.h>
sys\stat.h:24:#include <sys/types.h>
sys\timeb.h:16:#include <sys/types.h>
sys\utime.h:21:#include <sys/types.h>
wchar.h:50:#include <sys/types.h>

The best solution is to transition from using off_t in SQLite to some
local version, as is done with i64 u64 etc.

The next best solution (retaining the ugliness described earlier) is
to make sure that os.h in included before any header that might
include <sys/types.h>, such as <stdio.h>.

e


os.h:182:int sqlite3OsSeek(OsFile*, off_t offset);
os.h:184:int sqlite3OsTruncate(OsFile*, off_t size);
os.h:185:int sqlite3OsFileSize(OsFile*, off_t *pSize);
os_mac.c:347:int sqlite3OsSeek(OsFile *id, off_t offset){
os_mac.c:348:  off_t curSize;
os_mac.c:407:int sqlite3OsTruncate(OsFile *id, off_t nByte){
os_mac.c:423:int sqlite3OsFileSize(OsFile *id, off_t *pSize){
os_mac.h:23:    typedef SInt64 off_t;
os_mac.h:25:    typedef SInt32 off_t;
os_test.c:152:static off_t osTell(OsTestFile *pFile){
os_test.c:170:    off_t filesize;
os_test.c:204:  off_t offset;
os_test.c:298:  off_t offset;       /* The current offset from the start of the file */
os_test.c:299:  off_t end;          /* The byte just past the last byte read */
os_test.c:343:  off_t offset;       /* The current offset from the start of the file */
os_test.c:344:  off_t end;          /* The byte just past the last byte written */
os_test.c:406:int sqlite3OsTruncate(OsFile *id, off_t nByte){
os_test.c:415:int sqlite3OsFileSize(OsFile *id, off_t *pSize){
os_test.c:445:int sqlite3OsSeek(OsFile *id, off_t offset){
os_unix.c:665:int sqlite3OsSeek(OsFile *id, off_t offset){
os_unix.c:736:int sqlite3OsTruncate(OsFile *id, off_t nByte){
os_unix.c:745:int sqlite3OsFileSize(OsFile *id, off_t *pSize){
os_win.c:296:int sqlite3OsSeek(OsFile *id, off_t offset){
os_win.c:332:int sqlite3OsTruncate(OsFile *id, off_t nByte){
os_win.c:345:int sqlite3OsFileSize(OsFile *id, off_t *pSize){
os_win.c:350:  *pSize = (((off_t)upperBits)<<32) + lowerBits;
os_win.h:22:  typedef __int64 off_t;
os_win.h:25:  typedef long long off_t;
pager.c:193:  off_t stmtJSize;            /* Size of journal at stmt_begin() */
pager.c:231:  off_t journalOff;           /* Current byte offset in the journal file */
pager.c:232:  off_t journalHdr;           /* Byte offset to previous journal header */
pager.c:233:  off_t stmtHdrOff;           /* First journal header written this 
statement */
pager.c:234:  off_t stmtCksum;            /* cksumInit when statement was started */
pager.c:402:  off_t szJ;
pager.c:472:  off_t offset = 0;
pager.c:473:  off_t c = pPager->journalOff;
pager.c:565:  off_t journalSize,
pager.c:874:    sqlite3OsSeek(&pPager->fd, (pgno-1)*(off_t)pPager->pageSize);
pager.c:914:  off_t nMasterJournal;     /* Size of master journal file */
pager.c:999:      sqlite3OsSeek(&pPager->fd, pPager->pageSize*(off_t)(pPg->pgno-1));
pager.c:1026:  return sqlite3OsTruncate(&pPager->fd, pPager->pageSize*(off_t)nPage);
pager.c:1083:  off_t szJ;               /* Size of the journal file in bytes */
pager.c:1218:  off_t szJ;               /* Size of the full journal */
pager.c:1219:  off_t hdrOff;
pager.c:1227:    off_t os_szJ;
pager.c:1569:  off_t n;
pager.c:1855:        off_t jSz;
pager.c:1952:    sqlite3OsSeek(&pPager->fd, (pList->pgno-1)*(off_t)pPager->pageSize);
pager.c:2229:      sqlite3OsSeek(&pPager->fd, (pgno-1)*(off_t)pPager->pageSize);
pager.c:2234:        off_t fileSize;
test2.c:500:  off_t offset;

-=-

Reply via email to