summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorgeniusgogo <[email protected]>2013-12-22 21:26:21 +0800
committergeniusgogo <[email protected]>2013-12-22 21:26:21 +0800
commit7442414a74a909c4e60874c96eded1c739129778 (patch)
treeaa49d6b6b04c429e6296a7d9ece9306d1d8b53a6 /components
parent26e0137f15cb00208f28dcb8493d8a0789360076 (diff)
ARMCC complier is usable.
Diffstat (limited to 'components')
-rw-r--r--components/external/SQLite-3.8.1/SQLiteLib/sqlite3.c161
-rw-r--r--components/external/SQLite-3.8.1/src/os_rtthread.c94
2 files changed, 220 insertions, 35 deletions
diff --git a/components/external/SQLite-3.8.1/SQLiteLib/sqlite3.c b/components/external/SQLite-3.8.1/SQLiteLib/sqlite3.c
index 778e799282..789d6d1f4a 100644
--- a/components/external/SQLite-3.8.1/SQLiteLib/sqlite3.c
+++ b/components/external/SQLite-3.8.1/SQLiteLib/sqlite3.c
@@ -25,6 +25,71 @@
#ifndef SQLITE_API
# define SQLITE_API
#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 *****************************************/
/*
** 2001 September 15
@@ -22649,6 +22714,7 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
#if SQLITE_OS_RTTHREAD /* This file is used for rt-thread only */
/* #include <rtthread.h> */
+#include <dfs_posix.h>
/*
** Include code that is common to all os_*.c files
@@ -22863,6 +22929,51 @@ SQLITE_API int sqlite3_open_file_count = 0;
/************** End of os_common.h *******************************************/
/************** 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
** available in rt-thread.
@@ -23019,7 +23130,7 @@ static int sqlite3_os_type = 0;
# define SYSCALL sqlite3_syscall_ptr
#endif
-#include <dfs_posix.h>
+/* #include <dfs_posix.h> */
static int _Access(const char *pathname, int mode)
{
@@ -23110,10 +23221,10 @@ static struct rtthread_syscall {
#define osFstat ((int(*)(int,struct stat*))aSyscall[5].pCurrent)
{ "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 },
-#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 },
#define osUnlink ((int(*)(const char*))aSyscall[8].pCurrent)
@@ -23465,9 +23576,9 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
return SQLITE_OK;
#endif
- case EAGAIN:
+ case DFS_STATUS_EAGAIN:
case ETIMEDOUT:
- case EBUSY:
+ case DFS_STATUS_EBUSY:
case EINTR:
case ENOLCK:
/* random NFS retry error, unless during file system support
@@ -23506,17 +23617,17 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
/* invalid fd, unless during file system support introspection, in which
* it actually means what it says */
#endif
- case EIO:
- case EBADF:
- case EINVAL:
+ case DFS_STATUS_EIO:
+ case DFS_STATUS_EBADF:
+ case DFS_STATUS_EINVAL:
case ENOTCONN:
- case ENODEV:
- case ENXIO:
- case ENOENT:
+ case DFS_STATUS_ENODEV:
+ case DFS_STATUS_ENXIO:
+ case DFS_STATUS_ENOENT:
#ifdef ESTALE /* ESTALE is not defined on Interix systems */
case ESTALE:
#endif
- case ENOSYS:
+ case DFS_STATUS_ENOSYS:
/* these should force the client to close the file and reconnect */
default:
@@ -23573,11 +23684,14 @@ static void verifyDbFile(rtthreadFile *pFile){
pFile->ctrlFlags |= UNIXFILE_WARNED;
return;
}
+#warning " struct \"stat\" has no field \"st_nlink\""
+#ifndef RT_USING_SQLITE
if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){
sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath);
pFile->ctrlFlags |= UNIXFILE_WARNED;
return;
}
+#endif
}
/*
@@ -23760,7 +23874,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) {
if( rc<0 ){
/* failed to open/create the lock directory */
int tErrno = errno;
- if( EEXIST == tErrno ){
+ if( DFS_STATUS_EEXIST == tErrno ){
rc = SQLITE_BUSY;
} else {
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
@@ -23811,11 +23925,11 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
/* To fully unlock the database, delete the lock file */
assert( eFileLock==NO_LOCK );
rc = osRmdir(zLockFile);
- if( rc<0 && errno==ENOTDIR ) rc = osUnlink(zLockFile);
+ if( rc<0 && errno==DFS_STATUS_ENOTDIR ) rc = osUnlink(zLockFile);
if( rc<0 ){
int tErrno = errno;
rc = 0;
- if( ENOENT != tErrno ){
+ if( DFS_STATUS_ENOENT != tErrno ){
rc = SQLITE_IOERR_UNLOCK;
}
if( IS_LOCK_ERROR(rc) ){
@@ -24258,7 +24372,7 @@ static int rtthreadWrite(
SimulateDiskfullError(( wrote=0, amt=1 ));
if( amt>0 ){
- if( wrote<0 && pFile->lastErrno!=ENOSPC ){
+ if( wrote<0 && pFile->lastErrno!=DFS_STATUS_ENOSPC ){
/* lastErrno set by seekAndWrite */
return SQLITE_IOERR_WRITE;
}else{
@@ -25090,7 +25204,7 @@ static int rtthreadOpen(
fd = robust_open(zName, openFlags, openMode);
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. */
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
openFlags &= ~(O_RDWR|O_CREAT);
@@ -25148,7 +25262,7 @@ static int rtthreadDelete(
UNUSED_PARAMETER(NotUsed);
SimulateIOError(return SQLITE_IOERR_DELETE);
if( osUnlink(zPath)==(-1) ){
- if( errno==ENOENT ){
+ if( errno==DFS_STATUS_ENOENT ){
rc = SQLITE_IOERR_DELETE_NOENT;
}else{
rc = rtthreadLogError(SQLITE_IOERR_DELETE, "unlink", zPath);
@@ -25179,6 +25293,17 @@ static int rtthreadDelete(
**
** 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(
sqlite3_vfs *NotUsed, /* The VFS containing this xAccess method */
const char *zPath, /* Path of the file to examine */
diff --git a/components/external/SQLite-3.8.1/src/os_rtthread.c b/components/external/SQLite-3.8.1/src/os_rtthread.c
index a1d6b7017c..fb51b53685 100644
--- a/components/external/SQLite-3.8.1/src/os_rtthread.c
+++ b/components/external/SQLite-3.8.1/src/os_rtthread.c
@@ -16,12 +16,58 @@
#if SQLITE_OS_RTTHREAD /* This file is used for rt-thread only */
#include <rtthread.h>
+#include <dfs_posix.h>
/*
** Include code that is common to all os_*.c files
*/
#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
** available in rt-thread.
@@ -269,10 +315,10 @@ static struct rtthread_syscall {
#define osFstat ((int(*)(int,struct stat*))aSyscall[5].pCurrent)
{ "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 },
-#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 },
#define osUnlink ((int(*)(const char*))aSyscall[8].pCurrent)
@@ -624,9 +670,9 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
return SQLITE_OK;
#endif
- case EAGAIN:
+ case DFS_STATUS_EAGAIN:
case ETIMEDOUT:
- case EBUSY:
+ case DFS_STATUS_EBUSY:
case EINTR:
case ENOLCK:
/* random NFS retry error, unless during file system support
@@ -665,17 +711,17 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
/* invalid fd, unless during file system support introspection, in which
* it actually means what it says */
#endif
- case EIO:
- case EBADF:
- case EINVAL:
+ case DFS_STATUS_EIO:
+ case DFS_STATUS_EBADF:
+ case DFS_STATUS_EINVAL:
case ENOTCONN:
- case ENODEV:
- case ENXIO:
- case ENOENT:
+ case DFS_STATUS_ENODEV:
+ case DFS_STATUS_ENXIO:
+ case DFS_STATUS_ENOENT:
#ifdef ESTALE /* ESTALE is not defined on Interix systems */
case ESTALE:
#endif
- case ENOSYS:
+ case DFS_STATUS_ENOSYS:
/* these should force the client to close the file and reconnect */
default:
@@ -732,11 +778,14 @@ static void verifyDbFile(rtthreadFile *pFile){
pFile->ctrlFlags |= UNIXFILE_WARNED;
return;
}
+#warning " struct \"stat\" has no field \"st_nlink\""
+#ifndef RT_USING_SQLITE
if( buf.st_nlink==0 && (pFile->ctrlFlags & UNIXFILE_DELETE)==0 ){
sqlite3_log(SQLITE_WARNING, "file unlinked while open: %s", pFile->zPath);
pFile->ctrlFlags |= UNIXFILE_WARNED;
return;
}
+#endif
}
/*
@@ -919,7 +968,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) {
if( rc<0 ){
/* failed to open/create the lock directory */
int tErrno = errno;
- if( EEXIST == tErrno ){
+ if( DFS_STATUS_EEXIST == tErrno ){
rc = SQLITE_BUSY;
} else {
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
@@ -970,11 +1019,11 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
/* To fully unlock the database, delete the lock file */
assert( eFileLock==NO_LOCK );
rc = osRmdir(zLockFile);
- if( rc<0 && errno==ENOTDIR ) rc = osUnlink(zLockFile);
+ if( rc<0 && errno==DFS_STATUS_ENOTDIR ) rc = osUnlink(zLockFile);
if( rc<0 ){
int tErrno = errno;
rc = 0;
- if( ENOENT != tErrno ){
+ if( DFS_STATUS_ENOENT != tErrno ){
rc = SQLITE_IOERR_UNLOCK;
}
if( IS_LOCK_ERROR(rc) ){
@@ -1417,7 +1466,7 @@ static int rtthreadWrite(
SimulateDiskfullError(( wrote=0, amt=1 ));
if( amt>0 ){
- if( wrote<0 && pFile->lastErrno!=ENOSPC ){
+ if( wrote<0 && pFile->lastErrno!=DFS_STATUS_ENOSPC ){
/* lastErrno set by seekAndWrite */
return SQLITE_IOERR_WRITE;
}else{
@@ -2249,7 +2298,7 @@ static int rtthreadOpen(
fd = robust_open(zName, openFlags, openMode);
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. */
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
openFlags &= ~(O_RDWR|O_CREAT);
@@ -2307,7 +2356,7 @@ static int rtthreadDelete(
UNUSED_PARAMETER(NotUsed);
SimulateIOError(return SQLITE_IOERR_DELETE);
if( osUnlink(zPath)==(-1) ){
- if( errno==ENOENT ){
+ if( errno==DFS_STATUS_ENOENT ){
rc = SQLITE_IOERR_DELETE_NOENT;
}else{
rc = rtthreadLogError(SQLITE_IOERR_DELETE, "unlink", zPath);
@@ -2338,6 +2387,17 @@ static int rtthreadDelete(
**
** 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(
sqlite3_vfs *NotUsed, /* The VFS containing this xAccess method */
const char *zPath, /* Path of the file to examine */