diff --git a/third_party/sqlite3/os_unix.c b/third_party/sqlite3/os_unix.c index a36a94b1f..4eb0bbb91 100644 --- a/third_party/sqlite3/os_unix.c +++ b/third_party/sqlite3/os_unix.c @@ -47,6 +47,8 @@ #include "libc/stdio/rand.h" #include "libc/sysv/consts/lock.h" #include "third_party/sqlite3/sqliteInt.h" +#include "libc/sysv/consts/f.h" +#include "libc/dce.h" #if SQLITE_OS_UNIX /* This file is used on unix only */ /* @@ -3628,8 +3630,9 @@ static int full_fsync(int fd, int fullSync, int dataOnly){ struct stat buf; rc = osFstat(fd, &buf); } -#elif HAVE_FULLFSYNC - if( fullSync ){ +#elif HAVE_FULLFSYNC || defined(__COSMOPOLITAN__) + /* [jart] use runtime os detection */ + if( fullSync && F_FULLFSYNC != -1 ){ rc = osFcntl(fd, F_FULLFSYNC, 0); }else{ rc = 1; @@ -3642,7 +3645,13 @@ static int full_fsync(int fd, int fullSync, int dataOnly){ ** It'd be better to detect fullfsync support once and avoid ** the fcntl call every time sync is called. */ - if( rc ) rc = fsync(fd); + if( rc ) { + if( IsXnu() ){ + rc = fsync(fd); + }else{ + rc = fdatasync(fd); + } + } #elif defined(__APPLE__) /* fdatasync() on HFS+ doesn't yet flush the file size if it changed correctly diff --git a/third_party/sqlite3/shell.c b/third_party/sqlite3/shell.c index 2925662ab..d4c113186 100644 --- a/third_party/sqlite3/shell.c +++ b/third_party/sqlite3/shell.c @@ -140,7 +140,7 @@ typedef sqlite3_int64 i64; typedef sqlite3_uint64 u64; typedef unsigned char u8; #if SQLITE_USER_AUTHENTICATION -# include "sqlite3userauth.h" +# include "third_party/sqlite3/sqlite3userauth.h" #endif #if !defined(_WIN32) && !defined(WIN32) @@ -11265,6 +11265,7 @@ static void process_sqliterc( p->in = inSaved; p->lineno = savedLineno; sqlite3_free(zBuf); + errno = 0; /* [jart] clear error */ } /*