From 1d3282d6038bc327fea78482a6c991e05d76aab8 Mon Sep 17 00:00:00 2001
From: Leorize <alaviss@users.noreply.github.com>
Date: Wed, 10 Jan 2018 17:22:55 +0700
Subject: crypto: include <sys/mman.h> unless WAL is omitted

crypto_impl.c is included before os_unix.c, which means if an user
define OMIT_MEMLOCK, <sys/mman.h> won't be included, which is needed for
WAL

diff --git a/src/crypto_impl.c b/src/crypto_impl.c
index 8b024de..e5cb99d 100644
--- a/src/crypto_impl.c
+++ b/src/crypto_impl.c
@@ -38,11 +38,13 @@
 #include <errno.h>
 #include <unistd.h>
 #include <sys/resource.h>
-#include <sys/mman.h>
 #elif defined(_WIN32)
 #include <windows.h>
 #endif
 #endif
+#if !defined(SQLITE_OMIT_WAL) && SQLITE_OS_UNIX
+#include <sys/mman.h>
+#endif
 
 static volatile unsigned int default_flags = DEFAULT_CIPHER_FLAGS;
 static volatile unsigned char hmac_salt_mask = HMAC_SALT_MASK;
-- 
2.28.0


From ce7e259cd0d8346f481a1d3e88eaafabe764419f Mon Sep 17 00:00:00 2001
From: Leorize <alaviss@users.noreply.github.com>
Date: Wed, 10 Jan 2018 20:47:29 +0700
Subject: test1: fixes for Haiku


diff --git a/src/test1.c b/src/test1.c
index c3954e9..2ca98e3 100644
--- a/src/test1.c
+++ b/src/test1.c
@@ -6967,10 +6967,16 @@ static int SQLITE_TCLAPI test_getrusage(
   getrusage(RUSAGE_SELF, &r);
 
   sqlite3_snprintf(sizeof(buf), buf,
-    "ru_utime=%d.%06d ru_stime=%d.%06d ru_minflt=%d ru_majflt=%d", 
-    (int)r.ru_utime.tv_sec, (int)r.ru_utime.tv_usec, 
-    (int)r.ru_stime.tv_sec, (int)r.ru_stime.tv_usec, 
-    (int)r.ru_minflt, (int)r.ru_majflt
+    "ru_utime=%d.%06d ru_stime=%d.%06d"
+#ifndef __HAIKU__
+    " ru_minflt=%d ru_majflt=%d"
+#endif
+    ,
+    (int)r.ru_utime.tv_sec, (int)r.ru_utime.tv_usec,
+    (int)r.ru_stime.tv_sec, (int)r.ru_stime.tv_usec
+#ifndef __HAIKU__
+    , (int)r.ru_minflt, (int)r.ru_majflt
+#endif
   );
   Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
   return TCL_OK;
-- 
2.28.0

