提交 7d082849 编写于 作者: B Bernard Xiong

Merge pull request #219 from geniusgogo/SQLite_on_ARMCC

Sq lite on armcc
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
* SQLite compile macro * SQLite compile macro
*/ */
#define RT_USING_SQLITE #define RT_USING_SQLITE
2.
关注SQLite目录下的src/sqlite_config_rtthread.h
#define SQLITE_MINIMUM_FILE_DESCRIPTOR 0 #define SQLITE_MINIMUM_FILE_DESCRIPTOR 0
#define SQLITE_OMIT_LOAD_EXTENSION 1 #define SQLITE_OMIT_LOAD_EXTENSION 1
#define SQLITE_OMIT_WAL #define SQLITE_OMIT_WAL
...@@ -20,11 +22,11 @@ ...@@ -20,11 +22,11 @@
#define SQLITE_THREADSAFE 1 #define SQLITE_THREADSAFE 1
#define HAVE_READLINE 0 #define HAVE_READLINE 0
#define NDEBUG #define NDEBUG
#define _HAVE_SQLITE_CONFIG_H #define _HAVE_SQLITE_CONFIG_H
#define BUILD_sqlite #define BUILD_sqlite
#define SQLITE_OS_OTHER 1 #define SQLITE_OS_OTHER 1
#define SQLITE_OS_RTT 1 #define SQLITE_OS_RTTHREAD 1
2. 3.
用test目录下的test10.c来进行测试. 用test目录下的test10.c来进行测试.
推荐用mini2440bsp,因为板子的ram较大。 推荐用mini2440bsp,因为板子的ram较大。
......
...@@ -25,6 +25,71 @@ ...@@ -25,6 +25,71 @@
#ifndef SQLITE_API #ifndef SQLITE_API
# define SQLITE_API # define SQLITE_API
#endif #endif
/************** Begin file sqlite_config_rtthread.h **************************/
#ifndef _SQLITE_CONFIG_RTTHREAD_H_
#define _SQLITE_CONFIG_RTTHREAD_H_
/*
* SQLite compile macro
*/
#ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR
#define SQLITE_MINIMUM_FILE_DESCRIPTOR 0
#endif
#ifndef SQLITE_OMIT_LOAD_EXTENSION
#define SQLITE_OMIT_LOAD_EXTENSION 1
#endif
//#ifndef #define SQLITE_OMIT_WAL
#define SQLITE_OMIT_WAL
//#endif
#ifndef SQLITE_RTTHREAD_NO_WIDE
#define SQLITE_RTTHREAD_NO_WIDE 1
#endif
#ifndef SQLITE_ENABLE_LOCKING_STYLE
#define SQLITE_ENABLE_LOCKING_STYLE 0
#endif
#ifndef SQLITE_DISABLE_LOCKING_STYLE
#define SQLITE_DISABLE_LOCKING_STYLE 1
#endif
#ifndef SQLITE_TEMP_STORE
#define SQLITE_TEMP_STORE 1
#endif
#ifndef SQLITE_THREADSAFE
#define SQLITE_THREADSAFE 1
#endif
#ifndef HAVE_READLINE
#define HAVE_READLINE 0
#endif
#ifndef NDEBUG
#define NDEBUG
#endif
#ifndef _HAVE_SQLITE_CONFIG_H
#define _HAVE_SQLITE_CONFIG_H
#endif
#ifndef BUILD_sqlite
#define BUILD_sqlite
#endif
#ifndef SQLITE_OS_OTHER
#define SQLITE_OS_OTHER 1
#endif
#ifndef SQLITE_OS_RTTHREAD
#define SQLITE_OS_RTTHREAD 1
#endif
#endif
/************** End of sqlite_config_rtthread.h ******************************/
/************** Begin file sqlite3.h *****************************************/ /************** Begin file sqlite3.h *****************************************/
/* /*
** 2001 September 15 ** 2001 September 15
...@@ -22649,6 +22714,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ ...@@ -22649,6 +22714,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
#if SQLITE_OS_RTTHREAD /* This file is used for rt-thread only */ #if SQLITE_OS_RTTHREAD /* This file is used for rt-thread only */
/* #include <rtthread.h> */ /* #include <rtthread.h> */
#include <dfs_posix.h>
/* /*
** Include code that is common to all os_*.c files ** Include code that is common to all os_*.c files
...@@ -22863,6 +22929,51 @@ SQLITE_API int sqlite3_open_file_count = 0; ...@@ -22863,6 +22929,51 @@ SQLITE_API int sqlite3_open_file_count = 0;
/************** End of os_common.h *******************************************/ /************** End of os_common.h *******************************************/
/************** Continuing where we left off in os_rtthread.c ****************/ /************** Continuing where we left off in os_rtthread.c ****************/
#ifndef RT_USING_NEWLIB
#ifndef EINTR
#define EINTR 4 /* Interrupted system call */
#endif
#ifndef ENOLCK
#define ENOLCK 46 /* No record locks available */
#endif
#ifndef EACCES
#define EACCES 13 /* Permission denied */
#endif
#ifndef EPERM
#define EPERM 1 /* Operation not permitted */
#endif
#ifndef ETIMEDOUT
#define ETIMEDOUT 145 /* Connection timed out */
#endif
#ifndef ENOTCONN
#define ENOTCONN 134 /* Transport endpoint is not connected */
#endif
#if defined(__GNUC__) || defined(__ADSPBLACKFIN__)
int _gettimeofday(struct timeval *tp, void *ignore) __attribute__((weak));
int _gettimeofday(struct timeval *tp, void *ignore)
#elif defined(__CC_ARM)
__weak int _gettimeofday(struct timeval *tp, void *ignore)
#elif defined(__IAR_SYSTEMS_ICC__)
#if __VER__ > 540
__weak
#endif
int _gettimeofday(struct timeval *tp, void *ignore)
#else
int _gettimeofday(struct timeval *tp, void *ignore)
#endif
{
return 0;
}
#endif /* RT_USING_NEWLIB */
/* /*
** Compiling and using WAL mode requires several APIs that are not ** Compiling and using WAL mode requires several APIs that are not
** available in rt-thread. ** available in rt-thread.
...@@ -23019,7 +23130,7 @@ static int sqlite3_os_type = 0; ...@@ -23019,7 +23130,7 @@ static int sqlite3_os_type = 0;
# define SYSCALL sqlite3_syscall_ptr # define SYSCALL sqlite3_syscall_ptr
#endif #endif
#include <dfs_posix.h> /* #include <dfs_posix.h> */
static int _Access(const char *pathname, int mode) static int _Access(const char *pathname, int mode)
{ {
...@@ -23110,10 +23221,10 @@ static struct rtthread_syscall { ...@@ -23110,10 +23221,10 @@ static struct rtthread_syscall {
#define osFstat ((int(*)(int,struct stat*))aSyscall[5].pCurrent) #define osFstat ((int(*)(int,struct stat*))aSyscall[5].pCurrent)
{ "read", (sqlite3_syscall_ptr)read, 0 }, { "read", (sqlite3_syscall_ptr)read, 0 },
#define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[6].pCurrent) #define osRead ((int(*)(int,void*,size_t))aSyscall[6].pCurrent)
{ "write", (sqlite3_syscall_ptr)write, 0 }, { "write", (sqlite3_syscall_ptr)write, 0 },
#define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[7].pCurrent) #define osWrite ((int(*)(int,const void*,size_t))aSyscall[7].pCurrent)
{ "unlink", (sqlite3_syscall_ptr)unlink, 0 }, { "unlink", (sqlite3_syscall_ptr)unlink, 0 },
#define osUnlink ((int(*)(const char*))aSyscall[8].pCurrent) #define osUnlink ((int(*)(const char*))aSyscall[8].pCurrent)
...@@ -23465,9 +23576,9 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) { ...@@ -23465,9 +23576,9 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
return SQLITE_OK; return SQLITE_OK;
#endif #endif
case EAGAIN: case DFS_STATUS_EAGAIN:
case ETIMEDOUT: case ETIMEDOUT:
case EBUSY: case DFS_STATUS_EBUSY:
case EINTR: case EINTR:
case ENOLCK: case ENOLCK:
/* random NFS retry error, unless during file system support /* random NFS retry error, unless during file system support
...@@ -23506,17 +23617,17 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) { ...@@ -23506,17 +23617,17 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
/* invalid fd, unless during file system support introspection, in which /* invalid fd, unless during file system support introspection, in which
* it actually means what it says */ * it actually means what it says */
#endif #endif
case EIO: case DFS_STATUS_EIO:
case EBADF: case DFS_STATUS_EBADF:
case EINVAL: case DFS_STATUS_EINVAL:
case ENOTCONN: case ENOTCONN:
case ENODEV: case DFS_STATUS_ENODEV:
case ENXIO: case DFS_STATUS_ENXIO:
case ENOENT: case DFS_STATUS_ENOENT:
#ifdef ESTALE /* ESTALE is not defined on Interix systems */ #ifdef ESTALE /* ESTALE is not defined on Interix systems */
case ESTALE: case ESTALE:
#endif #endif
case ENOSYS: case DFS_STATUS_ENOSYS:
/* these should force the client to close the file and reconnect */ /* these should force the client to close the file and reconnect */
default: default:
...@@ -23573,11 +23684,14 @@ static void verifyDbFile(rtthreadFile *pFile){ ...@@ -23573,11 +23684,14 @@ static void verifyDbFile(rtthreadFile *pFile){
pFile->ctrlFlags |= UNIXFILE_WARNED; pFile->ctrlFlags |= UNIXFILE_WARNED;
return; return;
} }
#warning " struct \"stat\" has no field \"st_nlink\""
#ifndef RT_USING_SQLITE
if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){ if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){
sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath); sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath);
pFile->ctrlFlags |= UNIXFILE_WARNED; pFile->ctrlFlags |= UNIXFILE_WARNED;
return; return;
} }
#endif
} }
/* /*
...@@ -23760,7 +23874,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) { ...@@ -23760,7 +23874,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) {
if( rc<0 ){ if( rc<0 ){
/* failed to open/create the lock directory */ /* failed to open/create the lock directory */
int tErrno = errno; int tErrno = errno;
if( EEXIST == tErrno ){ if( DFS_STATUS_EEXIST == tErrno ){
rc = SQLITE_BUSY; rc = SQLITE_BUSY;
} else { } else {
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK); rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
...@@ -23811,11 +23925,11 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) { ...@@ -23811,11 +23925,11 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
/* To fully unlock the database, delete the lock file */ /* To fully unlock the database, delete the lock file */
assert( eFileLock==NO_LOCK ); assert( eFileLock==NO_LOCK );
rc = osRmdir(zLockFile); rc = osRmdir(zLockFile);
if( rc<0 && errno==ENOTDIR ) rc = osUnlink(zLockFile); if( rc<0 && errno==DFS_STATUS_ENOTDIR ) rc = osUnlink(zLockFile);
if( rc<0 ){ if( rc<0 ){
int tErrno = errno; int tErrno = errno;
rc = 0; rc = 0;
if( ENOENT != tErrno ){ if( DFS_STATUS_ENOENT != tErrno ){
rc = SQLITE_IOERR_UNLOCK; rc = SQLITE_IOERR_UNLOCK;
} }
if( IS_LOCK_ERROR(rc) ){ if( IS_LOCK_ERROR(rc) ){
...@@ -24258,7 +24372,7 @@ static int rtthreadWrite( ...@@ -24258,7 +24372,7 @@ static int rtthreadWrite(
SimulateDiskfullError(( wrote=0, amt=1 )); SimulateDiskfullError(( wrote=0, amt=1 ));
if( amt>0 ){ if( amt>0 ){
if( wrote<0 && pFile->lastErrno!=ENOSPC ){ if( wrote<0 && pFile->lastErrno!=DFS_STATUS_ENOSPC ){
/* lastErrno set by seekAndWrite */ /* lastErrno set by seekAndWrite */
return SQLITE_IOERR_WRITE; return SQLITE_IOERR_WRITE;
}else{ }else{
...@@ -25090,7 +25204,7 @@ static int rtthreadOpen( ...@@ -25090,7 +25204,7 @@ static int rtthreadOpen(
fd = robust_open(zName, openFlags, openMode); fd = robust_open(zName, openFlags, openMode);
OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags)); OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags));
if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){ if( fd<0 && errno!=DFS_STATUS_EISDIR && isReadWrite && !isExclusive ){
/* Failed to open the file for read/write access. Try read-only. */ /* Failed to open the file for read/write access. Try read-only. */
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE); flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
openFlags &= ~(O_RDWR|O_CREAT); openFlags &= ~(O_RDWR|O_CREAT);
...@@ -25148,7 +25262,7 @@ static int rtthreadDelete( ...@@ -25148,7 +25262,7 @@ static int rtthreadDelete(
UNUSED_PARAMETER(NotUsed); UNUSED_PARAMETER(NotUsed);
SimulateIOError(return SQLITE_IOERR_DELETE); SimulateIOError(return SQLITE_IOERR_DELETE);
if( osUnlink(zPath)==(-1) ){ if( osUnlink(zPath)==(-1) ){
if( errno==ENOENT ){ if( errno==DFS_STATUS_ENOENT ){
rc = SQLITE_IOERR_DELETE_NOENT; rc = SQLITE_IOERR_DELETE_NOENT;
}else{ }else{
rc = rtthreadLogError(SQLITE_IOERR_DELETE, "unlink", zPath); rc = rtthreadLogError(SQLITE_IOERR_DELETE, "unlink", zPath);
...@@ -25179,6 +25293,17 @@ static int rtthreadDelete( ...@@ -25179,6 +25293,17 @@ static int rtthreadDelete(
** **
** Otherwise return 0. ** Otherwise return 0.
*/ */
#ifndef F_OK
# define F_OK 0
#endif
#ifndef R_OK
# define R_OK 4
#endif
#ifndef W_OK
# define W_OK 2
#endif
static int rtthreadAccess( static int rtthreadAccess(
sqlite3_vfs *NotUsed, /* The VFS containing this xAccess method */ sqlite3_vfs *NotUsed, /* The VFS containing this xAccess method */
const char *zPath, /* Path of the file to examine */ const char *zPath, /* Path of the file to examine */
...@@ -346,6 +346,8 @@ SRC += \ ...@@ -346,6 +346,8 @@ SRC += \
parse.h \ parse.h \
config.h \ config.h \
sqlite3.h sqlite3.h
SRC += $(TOP)/src/sqlite_config_rtthread.h
# Source code to the test files. # Source code to the test files.
# #
......
...@@ -16,12 +16,58 @@ ...@@ -16,12 +16,58 @@
#if SQLITE_OS_RTTHREAD /* This file is used for rt-thread only */ #if SQLITE_OS_RTTHREAD /* This file is used for rt-thread only */
#include <rtthread.h> #include <rtthread.h>
#include <dfs_posix.h>
/* /*
** Include code that is common to all os_*.c files ** Include code that is common to all os_*.c files
*/ */
#include "os_common.h" #include "os_common.h"
#ifndef RT_USING_NEWLIB
#ifndef EINTR
#define EINTR 4 /* Interrupted system call */
#endif
#ifndef ENOLCK
#define ENOLCK 46 /* No record locks available */
#endif
#ifndef EACCES
#define EACCES 13 /* Permission denied */
#endif
#ifndef EPERM
#define EPERM 1 /* Operation not permitted */
#endif
#ifndef ETIMEDOUT
#define ETIMEDOUT 145 /* Connection timed out */
#endif
#ifndef ENOTCONN
#define ENOTCONN 134 /* Transport endpoint is not connected */
#endif
#if defined(__GNUC__) || defined(__ADSPBLACKFIN__)
int _gettimeofday(struct timeval *tp, void *ignore) __attribute__((weak));
int _gettimeofday(struct timeval *tp, void *ignore)
#elif defined(__CC_ARM)
__weak int _gettimeofday(struct timeval *tp, void *ignore)
#elif defined(__IAR_SYSTEMS_ICC__)
#if __VER__ > 540
__weak
#endif
int _gettimeofday(struct timeval *tp, void *ignore)
#else
int _gettimeofday(struct timeval *tp, void *ignore)
#endif
{
return 0;
}
#endif /* RT_USING_NEWLIB */
/* /*
** Compiling and using WAL mode requires several APIs that are not ** Compiling and using WAL mode requires several APIs that are not
** available in rt-thread. ** available in rt-thread.
...@@ -269,10 +315,10 @@ static struct rtthread_syscall { ...@@ -269,10 +315,10 @@ static struct rtthread_syscall {
#define osFstat ((int(*)(int,struct stat*))aSyscall[5].pCurrent) #define osFstat ((int(*)(int,struct stat*))aSyscall[5].pCurrent)
{ "read", (sqlite3_syscall_ptr)read, 0 }, { "read", (sqlite3_syscall_ptr)read, 0 },
#define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[6].pCurrent) #define osRead ((int(*)(int,void*,size_t))aSyscall[6].pCurrent)
{ "write", (sqlite3_syscall_ptr)write, 0 }, { "write", (sqlite3_syscall_ptr)write, 0 },
#define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[7].pCurrent) #define osWrite ((int(*)(int,const void*,size_t))aSyscall[7].pCurrent)
{ "unlink", (sqlite3_syscall_ptr)unlink, 0 }, { "unlink", (sqlite3_syscall_ptr)unlink, 0 },
#define osUnlink ((int(*)(const char*))aSyscall[8].pCurrent) #define osUnlink ((int(*)(const char*))aSyscall[8].pCurrent)
...@@ -624,9 +670,9 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) { ...@@ -624,9 +670,9 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
return SQLITE_OK; return SQLITE_OK;
#endif #endif
case EAGAIN: case DFS_STATUS_EAGAIN:
case ETIMEDOUT: case ETIMEDOUT:
case EBUSY: case DFS_STATUS_EBUSY:
case EINTR: case EINTR:
case ENOLCK: case ENOLCK:
/* random NFS retry error, unless during file system support /* random NFS retry error, unless during file system support
...@@ -665,17 +711,17 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) { ...@@ -665,17 +711,17 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
/* invalid fd, unless during file system support introspection, in which /* invalid fd, unless during file system support introspection, in which
* it actually means what it says */ * it actually means what it says */
#endif #endif
case EIO: case DFS_STATUS_EIO:
case EBADF: case DFS_STATUS_EBADF:
case EINVAL: case DFS_STATUS_EINVAL:
case ENOTCONN: case ENOTCONN:
case ENODEV: case DFS_STATUS_ENODEV:
case ENXIO: case DFS_STATUS_ENXIO:
case ENOENT: case DFS_STATUS_ENOENT:
#ifdef ESTALE /* ESTALE is not defined on Interix systems */ #ifdef ESTALE /* ESTALE is not defined on Interix systems */
case ESTALE: case ESTALE:
#endif #endif
case ENOSYS: case DFS_STATUS_ENOSYS:
/* these should force the client to close the file and reconnect */ /* these should force the client to close the file and reconnect */
default: default:
...@@ -732,11 +778,14 @@ static void verifyDbFile(rtthreadFile *pFile){ ...@@ -732,11 +778,14 @@ static void verifyDbFile(rtthreadFile *pFile){
pFile->ctrlFlags |= UNIXFILE_WARNED; pFile->ctrlFlags |= UNIXFILE_WARNED;
return; return;
} }
#warning " struct \"stat\" has no field \"st_nlink\""
#ifndef RT_USING_SQLITE
if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){ if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){
sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath); sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath);
pFile->ctrlFlags |= UNIXFILE_WARNED; pFile->ctrlFlags |= UNIXFILE_WARNED;
return; return;
} }
#endif
} }
/* /*
...@@ -919,7 +968,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) { ...@@ -919,7 +968,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) {
if( rc<0 ){ if( rc<0 ){
/* failed to open/create the lock directory */ /* failed to open/create the lock directory */
int tErrno = errno; int tErrno = errno;
if( EEXIST == tErrno ){ if( DFS_STATUS_EEXIST == tErrno ){
rc = SQLITE_BUSY; rc = SQLITE_BUSY;
} else { } else {
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK); rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
...@@ -970,11 +1019,11 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) { ...@@ -970,11 +1019,11 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
/* To fully unlock the database, delete the lock file */ /* To fully unlock the database, delete the lock file */
assert( eFileLock==NO_LOCK ); assert( eFileLock==NO_LOCK );
rc = osRmdir(zLockFile); rc = osRmdir(zLockFile);
if( rc<0 && errno==ENOTDIR ) rc = osUnlink(zLockFile); if( rc<0 && errno==DFS_STATUS_ENOTDIR ) rc = osUnlink(zLockFile);
if( rc<0 ){ if( rc<0 ){
int tErrno = errno; int tErrno = errno;
rc = 0; rc = 0;
if( ENOENT != tErrno ){ if( DFS_STATUS_ENOENT != tErrno ){
rc = SQLITE_IOERR_UNLOCK; rc = SQLITE_IOERR_UNLOCK;
} }
if( IS_LOCK_ERROR(rc) ){ if( IS_LOCK_ERROR(rc) ){
...@@ -1417,7 +1466,7 @@ static int rtthreadWrite( ...@@ -1417,7 +1466,7 @@ static int rtthreadWrite(
SimulateDiskfullError(( wrote=0, amt=1 )); SimulateDiskfullError(( wrote=0, amt=1 ));
if( amt>0 ){ if( amt>0 ){
if( wrote<0 && pFile->lastErrno!=ENOSPC ){ if( wrote<0 && pFile->lastErrno!=DFS_STATUS_ENOSPC ){
/* lastErrno set by seekAndWrite */ /* lastErrno set by seekAndWrite */
return SQLITE_IOERR_WRITE; return SQLITE_IOERR_WRITE;
}else{ }else{
...@@ -2249,7 +2298,7 @@ static int rtthreadOpen( ...@@ -2249,7 +2298,7 @@ static int rtthreadOpen(
fd = robust_open(zName, openFlags, openMode); fd = robust_open(zName, openFlags, openMode);
OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags)); OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags));
if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){ if( fd<0 && errno!=DFS_STATUS_EISDIR && isReadWrite && !isExclusive ){
/* Failed to open the file for read/write access. Try read-only. */ /* Failed to open the file for read/write access. Try read-only. */
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE); flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
openFlags &= ~(O_RDWR|O_CREAT); openFlags &= ~(O_RDWR|O_CREAT);
...@@ -2307,7 +2356,7 @@ static int rtthreadDelete( ...@@ -2307,7 +2356,7 @@ static int rtthreadDelete(
UNUSED_PARAMETER(NotUsed); UNUSED_PARAMETER(NotUsed);
SimulateIOError(return SQLITE_IOERR_DELETE); SimulateIOError(return SQLITE_IOERR_DELETE);
if( osUnlink(zPath)==(-1) ){ if( osUnlink(zPath)==(-1) ){
if( errno==ENOENT ){ if( errno==DFS_STATUS_ENOENT ){
rc = SQLITE_IOERR_DELETE_NOENT; rc = SQLITE_IOERR_DELETE_NOENT;
}else{ }else{
rc = rtthreadLogError(SQLITE_IOERR_DELETE, "unlink", zPath); rc = rtthreadLogError(SQLITE_IOERR_DELETE, "unlink", zPath);
...@@ -2338,6 +2387,17 @@ static int rtthreadDelete( ...@@ -2338,6 +2387,17 @@ static int rtthreadDelete(
** **
** Otherwise return 0. ** Otherwise return 0.
*/ */
#ifndef F_OK
# define F_OK 0
#endif
#ifndef R_OK
# define R_OK 4
#endif
#ifndef W_OK
# define W_OK 2
#endif
static int rtthreadAccess( static int rtthreadAccess(
sqlite3_vfs *NotUsed, /* The VFS containing this xAccess method */ sqlite3_vfs *NotUsed, /* The VFS containing this xAccess method */
const char *zPath, /* Path of the file to examine */ const char *zPath, /* Path of the file to examine */
......
#ifndef _SQLITE_CONFIG_RTTHREAD_H_
#define _SQLITE_CONFIG_RTTHREAD_H_
/*
* SQLite compile macro
*/
#ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR
#define SQLITE_MINIMUM_FILE_DESCRIPTOR 0
#endif
#ifndef SQLITE_OMIT_LOAD_EXTENSION
#define SQLITE_OMIT_LOAD_EXTENSION 1
#endif
//#ifndef #define SQLITE_OMIT_WAL
#define SQLITE_OMIT_WAL
//#endif
#ifndef SQLITE_RTTHREAD_NO_WIDE
#define SQLITE_RTTHREAD_NO_WIDE 1
#endif
#ifndef SQLITE_ENABLE_LOCKING_STYLE
#define SQLITE_ENABLE_LOCKING_STYLE 0
#endif
#ifndef SQLITE_DISABLE_LOCKING_STYLE
#define SQLITE_DISABLE_LOCKING_STYLE 1
#endif
#ifndef SQLITE_TEMP_STORE
#define SQLITE_TEMP_STORE 1
#endif
#ifndef SQLITE_THREADSAFE
#define SQLITE_THREADSAFE 1
#endif
#ifndef HAVE_READLINE
#define HAVE_READLINE 0
#endif
#ifndef NDEBUG
#define NDEBUG
#endif
#ifndef _HAVE_SQLITE_CONFIG_H
#define _HAVE_SQLITE_CONFIG_H
#endif
#ifndef BUILD_sqlite
#define BUILD_sqlite
#endif
#ifndef SQLITE_OS_OTHER
#define SQLITE_OS_OTHER 1
#endif
#ifndef SQLITE_OS_RTTHREAD
#define SQLITE_OS_RTTHREAD 1
#endif
#endif
...@@ -228,6 +228,7 @@ proc copy_file {filename} { ...@@ -228,6 +228,7 @@ proc copy_file {filename} {
# inlining opportunities. # inlining opportunities.
# #
foreach file { foreach file {
sqlite_config_rtthread.h
sqlite3.h sqlite3.h
sqliteInt.h sqliteInt.h
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册