Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Apply fixes to the build system and rename a few things in the bt code so that sqlite4.c can be compiled. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f0eee06cf05d77b88f49767d82c87e52 |
User & Date: | dan 2014-01-07 10:37:28.688 |
Context
2014-01-07
| ||
20:41 | Begin adding code to update the meta tree with the results of a merge. check-in: 4db4b4ceeb user: dan tags: trunk | |
10:37 | Apply fixes to the build system and rename a few things in the bt code so that sqlite4.c can be compiled. check-in: f0eee06cf0 user: dan tags: trunk | |
2014-01-06
| ||
20:30 | Add merging code. check-in: ad91883237 user: dan tags: trunk | |
Changes
Changes to main.mk.
︙ | ︙ | |||
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | # All of the source code files. # SRC = \ $(TOP)/src/alter.c \ $(TOP)/src/analyze.c \ $(TOP)/src/attach.c \ $(TOP)/src/auth.c \ $(TOP)/src/bt_unix.c \ $(TOP)/src/build.c \ $(TOP)/src/callback.c \ $(TOP)/src/complete.c \ $(TOP)/src/ctime.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/env.c \ $(TOP)/src/expr.c \ $(TOP)/src/fault.c \ $(TOP)/src/fkey.c \ $(TOP)/src/fts5.c \ $(TOP)/src/fts5func.c \ $(TOP)/src/func.c \ $(TOP)/src/global.c \ $(TOP)/src/hash.c \ $(TOP)/src/hash.h \ $(TOP)/src/hwtime.h \ $(TOP)/src/insert.c \ $(TOP)/src/kv.c \ $(TOP)/src/kv.h \ $(TOP)/src/kvlsm.c \ $(TOP)/src/kvmem.c \ $(TOP)/src/legacy.c \ $(TOP)/src/lsm.h \ $(TOP)/src/lsmInt.h \ $(TOP)/src/lsm_ckpt.c \ $(TOP)/src/lsm_file.c \ | > > > > > > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | # All of the source code files. # SRC = \ $(TOP)/src/alter.c \ $(TOP)/src/analyze.c \ $(TOP)/src/attach.c \ $(TOP)/src/auth.c \ $(TOP)/src/bt.h \ $(TOP)/src/btInt.h \ $(TOP)/src/bt_main.c \ $(TOP)/src/bt_lock.c \ $(TOP)/src/bt_log.c \ $(TOP)/src/bt_pager.c \ $(TOP)/src/bt_unix.c \ $(TOP)/src/bt_varint.c \ $(TOP)/src/build.c \ $(TOP)/src/callback.c \ $(TOP)/src/complete.c \ $(TOP)/src/ctime.c \ $(TOP)/src/date.c \ $(TOP)/src/delete.c \ $(TOP)/src/env.c \ $(TOP)/src/expr.c \ $(TOP)/src/fault.c \ $(TOP)/src/fkey.c \ $(TOP)/src/fts5.c \ $(TOP)/src/fts5func.c \ $(TOP)/src/func.c \ $(TOP)/src/global.c \ $(TOP)/src/hash.c \ $(TOP)/src/hash.h \ $(TOP)/src/hwtime.h \ $(TOP)/src/insert.c \ $(TOP)/src/kv.c \ $(TOP)/src/kv.h \ $(TOP)/src/kvbt.c \ $(TOP)/src/kvlsm.c \ $(TOP)/src/kvmem.c \ $(TOP)/src/legacy.c \ $(TOP)/src/lsm.h \ $(TOP)/src/lsmInt.h \ $(TOP)/src/lsm_ckpt.c \ $(TOP)/src/lsm_file.c \ |
︙ | ︙ |
Changes to src/bt_lock.c.
︙ | ︙ | |||
41 42 43 44 45 46 47 | ** functions enterGlobalMutex() and leaveGlobalMutex()). ** ** iDebugId: ** Each new connection is assigned a "debug-id". This contributes ** nothing to the operation of the library, but sometimes makes it ** easier to debug various problems. */ | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ** functions enterGlobalMutex() and leaveGlobalMutex()). ** ** iDebugId: ** Each new connection is assigned a "debug-id". This contributes ** nothing to the operation of the library, but sometimes makes it ** easier to debug various problems. */ static struct BtSharedData { BtShared *pDatabase; /* Linked list of all Database objects */ int iDebugId; /* Next free debugging id */ } gBtShared = {0, 0}; struct BtFile { BtFile *pNext; bt_file *pFd; |
︙ | ︙ |
Changes to src/bt_log.c.
︙ | ︙ | |||
186 187 188 189 190 191 192 | */ #define BYTESWAP32(x) ( \ (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8) \ + (((x)&0x00FF0000)>>8) + (((x)&0xFF000000)>>24) \ ) /* True if this is a little-endian build */ | | | | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | */ #define BYTESWAP32(x) ( \ (((x)&0x000000FF)<<24) + (((x)&0x0000FF00)<<8) \ + (((x)&0x00FF0000)>>8) + (((x)&0xFF000000)>>24) \ ) /* True if this is a little-endian build */ static const int btOne = 1; #define BTLOG_LITTLE_ENDIAN (*(u8 *)(&btOne)) /* ** Generate or extend an 8 byte checksum based on the data in ** array aByte[] and the initial values of aIn[0] and aIn[1] (or ** initial values of 0 and 0 if aIn==NULL). ** ** The checksum is written back into aOut[] before returning. |
︙ | ︙ |
Changes to src/bt_unix.c.
︙ | ︙ | |||
42 43 44 45 46 47 48 | #ifdef __ANDROID__ # define fdatasync(x) fsync(x) #endif /* ** An open file is an instance of the following object */ | | | | | | | | | | | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | #ifdef __ANDROID__ # define fdatasync(x) fsync(x) #endif /* ** An open file is an instance of the following object */ typedef struct BtPosixFile BtPosixFile; struct BtPosixFile { sqlite4_env *pSqlEnv; bt_env *pEnv; /* The run-time environment */ const char *zName; /* Full path to file */ int fd; /* The open file descriptor */ int shmfd; /* Shared memory file-descriptor */ int nShm; /* Number of entries in array apShm[] */ void **apShm; /* Array of 32K shared memory segments */ }; static char *btPosixShmFile(BtPosixFile *p){ char *zShm; int nName = strlen(p->zName); zShm = (char*)sqlite4_malloc(p->pSqlEnv, nName+4+1); if( zShm ){ memcpy(zShm, p->zName, nName); memcpy(&zShm[nName], "-shm", 5); } return zShm; } static int btPosixOsOpen( sqlite4_env *pSqlEnv, bt_env *pEnv, const char *zFile, int flags, bt_file **ppFile ){ int rc = SQLITE4_OK; BtPosixFile *p; p = (BtPosixFile*)sqlite4_malloc(pSqlEnv, sizeof(BtPosixFile)); if( p==0 ){ rc = btErrorBkpt(SQLITE4_NOMEM); }else{ int bReadonly = (flags & BT_OPEN_READONLY); int oflags = (bReadonly ? O_RDONLY : (O_RDWR|O_CREAT)); memset(p, 0, sizeof(BtPosixFile)); p->zName = zFile; p->pEnv = pEnv; p->pSqlEnv = pSqlEnv; p->fd = open(zFile, oflags, 0644); if( p->fd<0 ){ sqlite4_free(pSqlEnv, p); p = 0; rc = btErrorBkpt(SQLITE4_IOERR); } } *ppFile = (bt_file*)p; return rc; } static int btPosixOsSize(bt_file *pFile, i64 *pnByte){ int rc = SQLITE4_OK; BtPosixFile *p = (BtPosixFile *)pFile; struct stat sBuf; if( fstat(p->fd, &sBuf)!=0 ){ rc = SQLITE4_IOERR_FSTAT; }else{ *pnByte = sBuf.st_size; } return rc; } static int btPosixOsWrite( bt_file *pFile, /* File to write to */ i64 iOff, /* Offset to write to */ void *pData, /* Write data from this buffer */ int nData /* Bytes of data to write */ ){ int rc = SQLITE4_OK; BtPosixFile *p = (BtPosixFile *)pFile; off_t offset; offset = lseek(p->fd, (off_t)iOff, SEEK_SET); if( offset!=iOff ){ rc = btErrorBkpt(SQLITE4_IOERR); }else{ ssize_t prc = write(p->fd, pData, (size_t)nData); if( prc<0 ) rc = btErrorBkpt(SQLITE4_IOERR); } return rc; } static int btPosixOsTruncate( bt_file *pFile, /* File to write to */ i64 nSize /* Size to truncate file to */ ){ BtPosixFile *p = (BtPosixFile *)pFile; int rc = SQLITE4_OK; /* Return code */ int prc; /* Posix Return Code */ struct stat sStat; /* Result of fstat() invocation */ prc = fstat(p->fd, &sStat); if( prc==0 && sStat.st_size>nSize ){ prc = ftruncate(p->fd, (off_t)nSize); } if( prc<0 ) rc = btErrorBkpt(SQLITE4_IOERR); return rc; } static int btPosixOsRead( bt_file *pFile, /* File to read from */ i64 iOff, /* Offset to read from */ void *pData, /* Read data into this buffer */ int nData /* Bytes of data to read */ ){ int rc = SQLITE4_OK; BtPosixFile *p = (BtPosixFile *)pFile; off_t offset; offset = lseek(p->fd, (off_t)iOff, SEEK_SET); if( offset!=iOff ){ rc = btErrorBkpt(SQLITE4_IOERR); }else{ ssize_t prc = read(p->fd, pData, (size_t)nData); if( prc<0 ){ rc = btErrorBkpt(SQLITE4_IOERR); }else if( prc<nData ){ memset(&((u8 *)pData)[prc], 0, nData - prc); } } return rc; } static int btPosixOsSync(bt_file *pFile){ int rc = SQLITE4_OK; #ifndef SQLITE_NO_SYNC BtPosixFile *p = (BtPosixFile *)pFile; int prc = 0; #if 0 if( p->pMap ){ prc = msync(p->pMap, p->nMap, MS_SYNC); } #endif |
︙ | ︙ | |||
260 261 262 263 264 265 266 | return prc ? btErrorBkpt(SQLITE4_IOERR) : SQLITE4_OK; } #define btPosixLockToByte(iLock) (100 + (iLock)) int btPosixOsLock(bt_file *pFile, int iLock, int eType){ int rc = SQLITE4_OK; | | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | return prc ? btErrorBkpt(SQLITE4_IOERR) : SQLITE4_OK; } #define btPosixLockToByte(iLock) (100 + (iLock)) int btPosixOsLock(bt_file *pFile, int iLock, int eType){ int rc = SQLITE4_OK; BtPosixFile *p = (BtPosixFile *)pFile; static const short aType[3] = { F_UNLCK, F_RDLCK, F_WRLCK }; struct flock lock; assert( aType[BT_LOCK_UNLOCK]==F_UNLCK ); assert( aType[BT_LOCK_SHARED]==F_RDLCK ); assert( aType[BT_LOCK_EXCL]==F_WRLCK ); assert( eType>=0 && eType<(sizeof(aType)/sizeof(aType[0])) ); |
︙ | ︙ | |||
290 291 292 293 294 295 296 | } return rc; } int btPosixOsTestLock(bt_file *pFile, int iLock, int nLock, int eType){ int rc = SQLITE4_OK; | | | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | } return rc; } int btPosixOsTestLock(bt_file *pFile, int iLock, int nLock, int eType){ int rc = SQLITE4_OK; BtPosixFile *p = (BtPosixFile *)pFile; static const short aType[3] = { 0, F_RDLCK, F_WRLCK }; struct flock lock; assert( eType==BT_LOCK_SHARED || eType==BT_LOCK_EXCL ); assert( aType[BT_LOCK_SHARED]==F_RDLCK ); assert( aType[BT_LOCK_EXCL]==F_WRLCK ); assert( eType>=0 && eType<(sizeof(aType)/sizeof(aType[0])) ); |
︙ | ︙ | |||
316 317 318 319 320 321 322 | rc = SQLITE4_BUSY; } return rc; } int btPosixOsShmMap(bt_file *pFile, int iChunk, int sz, void **ppShm){ | | | | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | rc = SQLITE4_BUSY; } return rc; } int btPosixOsShmMap(bt_file *pFile, int iChunk, int sz, void **ppShm){ BtPosixFile *p = (BtPosixFile *)pFile; *ppShm = 0; assert( sz==BT_SHM_CHUNK_SIZE ); if( iChunk>=p->nShm ){ int i; void **apNew; int nNew = iChunk+1; off_t nReq = nNew * BT_SHM_CHUNK_SIZE; struct stat sStat; /* If the shared-memory file has not been opened, open it now. */ if( p->shmfd<=0 ){ char *zShm = btPosixShmFile(p); if( !zShm ) return btErrorBkpt(SQLITE4_NOMEM); p->shmfd = open(zShm, O_RDWR|O_CREAT, 0644); sqlite4_free(p->pSqlEnv, zShm); if( p->shmfd<0 ){ return btErrorBkpt(SQLITE4_IOERR); } } |
︙ | ︙ | |||
373 374 375 376 377 378 379 | return SQLITE4_OK; } void btPosixOsShmBarrier(bt_file *pFile){ } int btPosixOsShmUnmap(bt_file *pFile, int bDelete){ | | | | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | return SQLITE4_OK; } void btPosixOsShmBarrier(bt_file *pFile){ } int btPosixOsShmUnmap(bt_file *pFile, int bDelete){ BtPosixFile *p = (BtPosixFile *)pFile; if( p->shmfd>0 ){ int i; for(i=0; i<p->nShm; i++){ if( p->apShm[i] ){ munmap(p->apShm[i], BT_SHM_CHUNK_SIZE); p->apShm[i] = 0; } } close(p->shmfd); p->shmfd = 0; if( bDelete ){ char *zShm = btPosixShmFile(p); if( zShm ) unlink(zShm); sqlite4_free(p->pSqlEnv, zShm); } } return SQLITE4_OK; } static int btPosixOsClose(bt_file *pFile){ BtPosixFile *p = (BtPosixFile *)pFile; btPosixOsShmUnmap(pFile, 0); close(p->fd); sqlite4_free(p->pSqlEnv, p->apShm); sqlite4_free(p->pSqlEnv, p); return SQLITE4_OK; } |
︙ | ︙ |
Changes to tool/mksqlite4c.tcl.
︙ | ︙ | |||
87 88 89 90 91 92 93 94 95 96 97 98 99 100 | } # These are the header files used by SQLite. The first time any of these # files are seen in a #include statement in the C code, include the complete # text of the file in-line. The file only needs to be included once. # foreach hdr { hash.h hwtime.h keywordhash.h kv.h lsm.h lsmInt.h mutex.h | > > | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | } # These are the header files used by SQLite. The first time any of these # files are seen in a #include statement in the C code, include the complete # text of the file in-line. The file only needs to be included once. # foreach hdr { bt.h btInt.h hash.h hwtime.h keywordhash.h kv.h lsm.h lsmInt.h mutex.h |
︙ | ︙ | |||
254 255 256 257 258 259 260 261 262 263 264 265 266 267 | lsm_unix.c lsm_varint.c kv.c kvmem.c kvlsm.c rowset.c vdbemem.c vdbeaux.c vdbeapi.c vdbecodec.c vdbecursor.c vdbetrace.c | > > > > > > > | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | lsm_unix.c lsm_varint.c kv.c kvmem.c kvlsm.c rowset.c kvbt.c bt_lock.c bt_log.c bt_main.c bt_pager.c bt_unix.c bt_varint.c vdbemem.c vdbeaux.c vdbeapi.c vdbecodec.c vdbecursor.c vdbetrace.c |
︙ | ︙ |