aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2023-08-03 12:41:30 +0000
committerdrh <>2023-08-03 12:41:30 +0000
commit9b1334b7d3a31f80e43e3f467de38c8c645830bb (patch)
treefa7597448540efae8e41889398eb89bb172e56e5 /src
parentc874d60353c0a3ef592e1e77129b2b083a01af7f (diff)
downloadsqlite-9b1334b7d3a31f80e43e3f467de38c8c645830bb.tar.gz
sqlite-9b1334b7d3a31f80e43e3f467de38c8c645830bb.zip
Unix builds now assume the presence of nanosleep() in the standard library.
The -DHAVE_NANOSLEEP=0 compile-time option can be used to build on systems (if any still exist) where this is not the case. FossilOrigin-Name: 779d5dc8797ea246d0397f7e94b1be716b0baa735e8d9f5a6fc4cffd887a7420
Diffstat (limited to 'src')
-rw-r--r--src/main.c4
-rw-r--r--src/os_unix.c9
2 files changed, 9 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 8f21af13e..35851b64e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1665,9 +1665,9 @@ static int sqliteDefaultBusyCallback(
void *ptr, /* Database connection */
int count /* Number of times table has been busy */
){
-#if SQLITE_OS_WIN || HAVE_USLEEP
+#if SQLITE_OS_WIN || !defined(HAVE_NANOSLEEP) || HAVE_NANOSLEEP
/* This case is for systems that have support for sleeping for fractions of
- ** a second. Examples: All windows systems, unix systems with usleep() */
+ ** a second. Examples: All windows systems, unix systems with nanosleep() */
static const u8 delays[] =
{ 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 };
static const u8 totals[] =
diff --git a/src/os_unix.c b/src/os_unix.c
index aed4ac213..59f67d142 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -6715,12 +6715,17 @@ static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){
** than the argument.
*/
static int unixSleep(sqlite3_vfs *NotUsed, int microseconds){
-#if OS_VXWORKS || _POSIX_C_SOURCE >= 199309L
+#if !defined(HAVE_NANOSLEEP) || HAVE_NANOSLEEP+0
struct timespec sp;
-
sp.tv_sec = microseconds / 1000000;
sp.tv_nsec = (microseconds % 1000000) * 1000;
+
+ /* Almost all modern unix systems support nanosleep(). But if you are
+ ** compiling for one of the rare exceptions, you can use
+ ** -DHAVE_NANOSLEEP=0 (perhaps in conjuction with -DHAVE_USLEEP if
+ ** usleep() is available) in order to bypass the use of nanosleep() */
nanosleep(&sp, NULL);
+
UNUSED_PARAMETER(NotUsed);
return microseconds;
#elif defined(HAVE_USLEEP) && HAVE_USLEEP