mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Get SQLite to build
* changed headers * removed redundant declarations * ran clang-format * added sqlite3.mk
This commit is contained in:
parent
644f290035
commit
919b6fec10
156 changed files with 2847 additions and 6772 deletions
85
third_party/sqlite3/os_unix.c
vendored
85
third_party/sqlite3/os_unix.c
vendored
|
@ -43,8 +43,9 @@
|
|||
** * Definitions of sqlite3_vfs objects for all locking methods
|
||||
** plus implementations of sqlite3_os_init() and sqlite3_os_end().
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#if SQLITE_OS_UNIX /* This file is used on unix only */
|
||||
#include "third_party/sqlite3/sqliteInt.h"
|
||||
#if SQLITE_OS_UNIX /* This file is used on unix only */
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** There are various methods for file locking used for concurrency
|
||||
|
@ -87,16 +88,22 @@
|
|||
/*
|
||||
** standard include files.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
|
||||
# include <sys/mman.h>
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/flock.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/isystem/unistd.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/mremap.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/ok.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/time/struct/tm.h"
|
||||
#include "libc/time/time.h"
|
||||
#if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE > 0
|
||||
#include "libc/mem/mem.h"
|
||||
#endif
|
||||
|
||||
#if SQLITE_ENABLE_LOCKING_STYLE
|
||||
|
@ -134,9 +141,10 @@
|
|||
|
||||
|
||||
#if OS_VXWORKS
|
||||
# include <sys/ioctl.h>
|
||||
# include <semaphore.h>
|
||||
# include <limits.h>
|
||||
#include <semaphore.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "libc/limits.h"
|
||||
#endif /* OS_VXWORKS */
|
||||
|
||||
#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
|
||||
|
@ -144,7 +152,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_UTIME
|
||||
# include <utime.h>
|
||||
#include "libc/time/time.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -297,7 +305,7 @@ static pid_t randomnessPid = 0;
|
|||
/*
|
||||
** Include code that is common to all os_*.c files
|
||||
*/
|
||||
#include "os_common.h"
|
||||
#include "third_party/sqlite3/os_common.h"
|
||||
|
||||
/*
|
||||
** Define various macros that are missing from some systems.
|
||||
|
@ -861,27 +869,22 @@ static int robust_ftruncate(int h, sqlite3_int64 sz){
|
|||
** should handle ENOLCK, ENOTSUP, EOPNOTSUPP separately.
|
||||
*/
|
||||
static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
|
||||
assert( (sqliteIOErr == SQLITE_IOERR_LOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_UNLOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_RDLOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) );
|
||||
switch (posixError) {
|
||||
case EACCES:
|
||||
case EAGAIN:
|
||||
case ETIMEDOUT:
|
||||
case EBUSY:
|
||||
case EINTR:
|
||||
case ENOLCK:
|
||||
/* random NFS retry error, unless during file system support
|
||||
assert((sqliteIOErr == SQLITE_IOERR_LOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_UNLOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_RDLOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK));
|
||||
// changed switch to if-else
|
||||
if (posixError == EACCES || posixError == EAGAIN || posixError == ETIMEDOUT ||
|
||||
posixError == EBUSY || posixError == EINTR || posixError == ENOLCK)
|
||||
/* random NFS retry error, unless during file system support
|
||||
* introspection, in which it actually means what it says */
|
||||
return SQLITE_BUSY;
|
||||
|
||||
case EPERM:
|
||||
|
||||
else if (posixError == EPERM)
|
||||
return SQLITE_PERM;
|
||||
|
||||
default:
|
||||
|
||||
else
|
||||
return sqliteIOErr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -3382,17 +3385,17 @@ static int unixRead(
|
|||
** prior to returning to the application by the sqlite3ApiExit()
|
||||
** routine.
|
||||
*/
|
||||
switch( pFile->lastErrno ){
|
||||
case ERANGE:
|
||||
case EIO:
|
||||
// changed switch to if-else
|
||||
if (pFile->lastErrno == ERANGE || pFile->lastErrno == EIO
|
||||
#ifdef ENXIO
|
||||
case ENXIO:
|
||||
|| pFile->lastErrno == ENXIO
|
||||
#endif
|
||||
#ifdef EDEVERR
|
||||
case EDEVERR:
|
||||
|| pFile->lastErrno == EDEVERR
|
||||
#endif
|
||||
return SQLITE_IOERR_CORRUPTFS;
|
||||
}
|
||||
)
|
||||
return SQLITE_IOERR_CORRUPTFS;
|
||||
|
||||
return SQLITE_IOERR_READ;
|
||||
}else{
|
||||
storeLastErrno(pFile, 0); /* not a system error */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue