Hi,

    use these definitions.

    -DOS_VXWORKS_660=660            \
    -DOS_VXWORKS_670=670            \
    -DOS_VXWORKS=OS_VXWORKS_670        \
    -DSQLITE_HOMEGROWN_RECURSIVE_MUTEX    \
    -DSQLITE_ENABLE_LOCKING_STYLE=1        \
    -DSQLITE_OMIT_LOAD_EXTENSION

and below is my patch with sqlite 3.6.17.

*** sqlite3.c.orig    Tue Aug 11 03:54:50 2009
--- sqlite3.c    Wed Aug 12 13:43:51 2009
***************
*** 19,24 ****
--- 19,28 ----
  **
  ** This amalgamation was generated on 2009-08-10 19:53:32 UTC.
  */
+ #if defined(OS_VXWORKS)
+ #include <vxWorks.h>
+ #endif /* OS_VXWORKS */
+
  #define SQLITE_CORE 1
  #define SQLITE_AMALGAMATION 1
  #ifndef SQLITE_PRIVATE
***************
*** 20983,20989 ****
--- 20987,20999 ----
  #include <sys/stat.h>
  #include <fcntl.h>
  #include <unistd.h>
+
+ #if defined(OS_VXWORKS) && defined(_WRS_KERNEL)
+ #include <sys/times.h>
+ #else
  #include <sys/time.h>
+ #endif /* OS_VXWORKS */
+
  #include <errno.h>

  #if SQLITE_ENABLE_LOCKING_STYLE
***************
*** 23171,23177 ****
--- 23181,23189 ----
    /* Otherwise see if some other process holds it. */
    if( !reserved ){
      sem_t *pSem = pFile->pOpen->pSem;
+ #if !defined(OS_VXWORKS)
      struct stat statBuf;
+ #endif

      if( sem_trywait(pSem)==-1 ){
        int tErrno = errno;
***************
*** 23224,23230 ****
--- 23236,23244 ----
  */
  static int semLock(sqlite3_file *id, int locktype) {
    unixFile *pFile = (unixFile*)id;
+ #if !defined(OS_VXWORKS)
    int fd;
+ #endif
    sem_t *pSem = pFile->pOpen->pSem;
    int rc = SQLITE_OK;

***************
*** 23293,23299 ****
--- 23307,23317 ----
  /*
   ** Close a file.
   */
+ #if (OS_VXWORKS < 600)
  static int semClose(sqlite3_file *id) {
+ #else
+ static int semClose_native(sqlite3_file *id) {
+ #endif
    if( id ){
      unixFile *pFile = (unixFile*)id;
      semUnlock(id, NO_LOCK);
***************
*** 23831,23837 ****
--- 23849,23861 ----
      }
      return -1;
    }
+
+ #if defined(OS_VXWORKS) && defined(_WRS_KERNEL)
+   got = write(id->h, (char *)pBuf, cnt);
+ #else
    got = write(id->h, pBuf, cnt);
+ #endif /* OS_VXWORKS */
+
  #endif
    TIMER_END;
    if( got<0 ){
***************
*** 24310,24316 ****
--- 24334,24344 ----
  IOMETHODS(
    semIoFinder,              /* Finder function name */
    semIoMethods,             /* sqlite3_io_methods object name */
+ #if (OS_VXWORKS < 600)
    semClose,                 /* xClose method */
+ #else
+   semClose_native,          /* xClose method */
+ #endif
    semLock,                  /* xLock method */
    semUnlock,                /* xUnlock method */
    semCheckReservedLock      /* xCheckReservedLock method */
***************
*** 25087,25093 ****
    ** tests repeatable.
    */
    memset(zBuf, 0, nBuf);
! #if !defined(SQLITE_TEST)
    {
      int pid, fd;
      fd = open("/dev/urandom", O_RDONLY);
--- 25115,25121 ----
    ** tests repeatable.
    */
    memset(zBuf, 0, nBuf);
! #if !defined(SQLITE_TEST) && !defined(OS_VXWORKS)
    {
      int pid, fd;
      fd = open("/dev/urandom", O_RDONLY);

I'v tested it on VxWorks 6.6/6.7 with both DKM and RTP mode.

2009/8/24 mly_hlmgood <mly_hlmg...@163.com>

> Hi,
>  I am puzzled by porting sqlite to VxWorks. can you help me.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to