Fossil SCM

Support for using 'sys/mman.h' when compiling for POSIX.

mistachkin 2018-03-20 17:10 trunk merge
Commit d5ca5384a07b700f710204935d991833aa19c96d4c42c8e6c1035a74c9361097
--- Makefile.in
+++ Makefile.in
@@ -43,10 +43,11 @@
4343
BCCFLAGS = @CPPFLAGS@ @CFLAGS@
4444
TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
4545
INSTALLDIR = $(DESTDIR)@prefix@/bin
4646
USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
4747
USE_LINENOISE = @USE_LINENOISE@
48
+USE_MMAN_H = @USE_MMAN_H@
4849
USE_SEE = @USE_SEE@
4950
FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
5051
5152
include $(SRCDIR)/main.mk
5253
5354
--- Makefile.in
+++ Makefile.in
@@ -43,10 +43,11 @@
43 BCCFLAGS = @CPPFLAGS@ @CFLAGS@
44 TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
45 INSTALLDIR = $(DESTDIR)@prefix@/bin
46 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
47 USE_LINENOISE = @USE_LINENOISE@
 
48 USE_SEE = @USE_SEE@
49 FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
50
51 include $(SRCDIR)/main.mk
52
53
--- Makefile.in
+++ Makefile.in
@@ -43,10 +43,11 @@
43 BCCFLAGS = @CPPFLAGS@ @CFLAGS@
44 TCCFLAGS = @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H
45 INSTALLDIR = $(DESTDIR)@prefix@/bin
46 USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@
47 USE_LINENOISE = @USE_LINENOISE@
48 USE_MMAN_H = @USE_MMAN_H@
49 USE_SEE = @USE_SEE@
50 FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@
51
52 include $(SRCDIR)/main.mk
53
54
+8
--- auto.def
+++ auto.def
@@ -15,10 +15,11 @@
1515
with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
1616
with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
1717
with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
1818
with-tcl-private-stubs=0
1919
=> {Enable Tcl integration via private stubs mechanism}
20
+ with-mman=0 => {Enable use of POSIX memory APIs from "sys/mman.h"}
2021
with-see=0 => {Enable the SQLite Encryption Extension (SEE)}
2122
internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
2223
static=0 => {Link a static executable}
2324
fusefs=1 => {Disable the Fuse Filesystem}
2425
fossil-debug=0 => {Build with fossil debugging enabled}
@@ -40,10 +41,11 @@
4041
define EXTRA_CFLAGS "-Wall"
4142
define EXTRA_LDFLAGS ""
4243
define USE_SYSTEM_SQLITE 0
4344
define USE_LINENOISE 0
4445
define FOSSIL_ENABLE_MINIZ 0
46
+define USE_MMAN_H 0
4547
define USE_SEE 0
4648
4749
# This procedure is a customized version of "cc-check-function-in-lib",
4850
# that does not modify the LIBS variable. Its use prevents prematurely
4951
# pulling in libraries that will be added later anyhow (e.g. "-ldl").
@@ -141,10 +143,16 @@
141143
142144
if {[opt-bool no-opt]} {
143145
define CFLAGS {-g -O0 -Wall}
144146
msg-result "Builting without compiler optimization"
145147
}
148
+
149
+if {[opt-bool with-mman]} {
150
+ define-append EXTRA_CFLAGS -DUSE_MMAN_H
151
+ define USE_MMAN_H 1
152
+ msg-result "Enabling \"sys/mman.h\" support"
153
+}
146154
147155
if {[opt-bool with-see]} {
148156
define-append EXTRA_CFLAGS -DUSE_SEE
149157
define USE_SEE 1
150158
msg-result "Enabling encryption support"
151159
--- auto.def
+++ auto.def
@@ -15,10 +15,11 @@
15 with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
16 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
17 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
18 with-tcl-private-stubs=0
19 => {Enable Tcl integration via private stubs mechanism}
 
20 with-see=0 => {Enable the SQLite Encryption Extension (SEE)}
21 internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
22 static=0 => {Link a static executable}
23 fusefs=1 => {Disable the Fuse Filesystem}
24 fossil-debug=0 => {Build with fossil debugging enabled}
@@ -40,10 +41,11 @@
40 define EXTRA_CFLAGS "-Wall"
41 define EXTRA_LDFLAGS ""
42 define USE_SYSTEM_SQLITE 0
43 define USE_LINENOISE 0
44 define FOSSIL_ENABLE_MINIZ 0
 
45 define USE_SEE 0
46
47 # This procedure is a customized version of "cc-check-function-in-lib",
48 # that does not modify the LIBS variable. Its use prevents prematurely
49 # pulling in libraries that will be added later anyhow (e.g. "-ldl").
@@ -141,10 +143,16 @@
141
142 if {[opt-bool no-opt]} {
143 define CFLAGS {-g -O0 -Wall}
144 msg-result "Builting without compiler optimization"
145 }
 
 
 
 
 
 
146
147 if {[opt-bool with-see]} {
148 define-append EXTRA_CFLAGS -DUSE_SEE
149 define USE_SEE 1
150 msg-result "Enabling encryption support"
151
--- auto.def
+++ auto.def
@@ -15,10 +15,11 @@
15 with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
16 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
17 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
18 with-tcl-private-stubs=0
19 => {Enable Tcl integration via private stubs mechanism}
20 with-mman=0 => {Enable use of POSIX memory APIs from "sys/mman.h"}
21 with-see=0 => {Enable the SQLite Encryption Extension (SEE)}
22 internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
23 static=0 => {Link a static executable}
24 fusefs=1 => {Disable the Fuse Filesystem}
25 fossil-debug=0 => {Build with fossil debugging enabled}
@@ -40,10 +41,11 @@
41 define EXTRA_CFLAGS "-Wall"
42 define EXTRA_LDFLAGS ""
43 define USE_SYSTEM_SQLITE 0
44 define USE_LINENOISE 0
45 define FOSSIL_ENABLE_MINIZ 0
46 define USE_MMAN_H 0
47 define USE_SEE 0
48
49 # This procedure is a customized version of "cc-check-function-in-lib",
50 # that does not modify the LIBS variable. Its use prevents prematurely
51 # pulling in libraries that will be added later anyhow (e.g. "-ldl").
@@ -141,10 +143,16 @@
143
144 if {[opt-bool no-opt]} {
145 define CFLAGS {-g -O0 -Wall}
146 msg-result "Builting without compiler optimization"
147 }
148
149 if {[opt-bool with-mman]} {
150 define-append EXTRA_CFLAGS -DUSE_MMAN_H
151 define USE_MMAN_H 1
152 msg-result "Enabling \"sys/mman.h\" support"
153 }
154
155 if {[opt-bool with-see]} {
156 define-append EXTRA_CFLAGS -DUSE_SEE
157 define USE_SEE 1
158 msg-result "Enabling encryption support"
159
+7
--- src/main.c
+++ src/main.c
@@ -920,16 +920,20 @@
920920
#if defined(FOSSIL_ENABLE_TCL)
921921
int rc;
922922
const char *zRc;
923923
#endif
924924
Stmt q;
925
+ size_t pageSize = 0;
925926
blob_zero(pOut);
926927
blob_appendf(pOut, "This is fossil version %s\n", get_version());
927928
if( !bVerbose ) return;
928929
blob_appendf(pOut, "Compiled on %s %s using %s (%d-bit)\n",
929930
__DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
930931
blob_appendf(pOut, "Schema version %s\n", AUX_SCHEMA_MAX);
932
+ fossil_get_page_size(&pageSize);
933
+ blob_appendf(pOut, "Detected memory page size is %lu bytes\n",
934
+ (unsigned long)pageSize);
931935
#if defined(FOSSIL_ENABLE_MINIZ)
932936
blob_appendf(pOut, "miniz %s, loaded %s\n", MZ_VERSION, mz_version());
933937
#else
934938
blob_appendf(pOut, "zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
935939
#endif
@@ -992,10 +996,13 @@
992996
blob_append(pOut, "FOSSIL_STATIC_BUILD\n", -1);
993997
#endif
994998
#if defined(HAVE_PLEDGE)
995999
blob_append(pOut, "HAVE_PLEDGE\n", -1);
9961000
#endif
1001
+#if defined(USE_MMAN_H)
1002
+ blob_append(pOut, "USE_MMAN_H\n", -1);
1003
+#endif
9971004
#if defined(USE_SEE)
9981005
blob_append(pOut, "USE_SEE\n", -1);
9991006
#endif
10001007
#if defined(FOSSIL_ALLOW_OUT_OF_ORDER_DATES)
10011008
blob_append(pOut, "FOSSIL_ALLOW_OUT_OF_ORDER_DATES\n");
10021009
--- src/main.c
+++ src/main.c
@@ -920,16 +920,20 @@
920 #if defined(FOSSIL_ENABLE_TCL)
921 int rc;
922 const char *zRc;
923 #endif
924 Stmt q;
 
925 blob_zero(pOut);
926 blob_appendf(pOut, "This is fossil version %s\n", get_version());
927 if( !bVerbose ) return;
928 blob_appendf(pOut, "Compiled on %s %s using %s (%d-bit)\n",
929 __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
930 blob_appendf(pOut, "Schema version %s\n", AUX_SCHEMA_MAX);
 
 
 
931 #if defined(FOSSIL_ENABLE_MINIZ)
932 blob_appendf(pOut, "miniz %s, loaded %s\n", MZ_VERSION, mz_version());
933 #else
934 blob_appendf(pOut, "zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
935 #endif
@@ -992,10 +996,13 @@
992 blob_append(pOut, "FOSSIL_STATIC_BUILD\n", -1);
993 #endif
994 #if defined(HAVE_PLEDGE)
995 blob_append(pOut, "HAVE_PLEDGE\n", -1);
996 #endif
 
 
 
997 #if defined(USE_SEE)
998 blob_append(pOut, "USE_SEE\n", -1);
999 #endif
1000 #if defined(FOSSIL_ALLOW_OUT_OF_ORDER_DATES)
1001 blob_append(pOut, "FOSSIL_ALLOW_OUT_OF_ORDER_DATES\n");
1002
--- src/main.c
+++ src/main.c
@@ -920,16 +920,20 @@
920 #if defined(FOSSIL_ENABLE_TCL)
921 int rc;
922 const char *zRc;
923 #endif
924 Stmt q;
925 size_t pageSize = 0;
926 blob_zero(pOut);
927 blob_appendf(pOut, "This is fossil version %s\n", get_version());
928 if( !bVerbose ) return;
929 blob_appendf(pOut, "Compiled on %s %s using %s (%d-bit)\n",
930 __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
931 blob_appendf(pOut, "Schema version %s\n", AUX_SCHEMA_MAX);
932 fossil_get_page_size(&pageSize);
933 blob_appendf(pOut, "Detected memory page size is %lu bytes\n",
934 (unsigned long)pageSize);
935 #if defined(FOSSIL_ENABLE_MINIZ)
936 blob_appendf(pOut, "miniz %s, loaded %s\n", MZ_VERSION, mz_version());
937 #else
938 blob_appendf(pOut, "zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
939 #endif
@@ -992,10 +996,13 @@
996 blob_append(pOut, "FOSSIL_STATIC_BUILD\n", -1);
997 #endif
998 #if defined(HAVE_PLEDGE)
999 blob_append(pOut, "HAVE_PLEDGE\n", -1);
1000 #endif
1001 #if defined(USE_MMAN_H)
1002 blob_append(pOut, "USE_MMAN_H\n", -1);
1003 #endif
1004 #if defined(USE_SEE)
1005 blob_append(pOut, "USE_SEE\n", -1);
1006 #endif
1007 #if defined(FOSSIL_ALLOW_OUT_OF_ORDER_DATES)
1008 blob_append(pOut, "FOSSIL_ALLOW_OUT_OF_ORDER_DATES\n");
1009
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -623,10 +623,14 @@
623623
# FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
624624
625625
#### Use 'system' SQLite
626626
#
627627
# USE_SYSTEM_SQLITE = 1
628
+
629
+#### Use POSIX memory APIs from "sys/mman.h"
630
+#
631
+# USE_MMAN_H = 1
628632
629633
#### Use the SQLite Encryption Extension
630634
#
631635
# USE_SEE = 1
632636
@@ -860,10 +864,16 @@
860864
# With JSON support
861865
ifdef FOSSIL_ENABLE_JSON
862866
TCC += -DFOSSIL_ENABLE_JSON=1
863867
RCC += -DFOSSIL_ENABLE_JSON=1
864868
endif
869
+
870
+# With "sys/mman.h" support
871
+ifdef USE_MMAN_H
872
+TCC += -DUSE_MMAN_H=1
873
+RCC += -DUSE_MMAN_H=1
874
+endif
865875
866876
# With SQLite Encryption Extension support
867877
ifdef USE_SEE
868878
TCC += -DUSE_SEE=1
869879
RCC += -DUSE_SEE=1
870880
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -623,10 +623,14 @@
623 # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
624
625 #### Use 'system' SQLite
626 #
627 # USE_SYSTEM_SQLITE = 1
 
 
 
 
628
629 #### Use the SQLite Encryption Extension
630 #
631 # USE_SEE = 1
632
@@ -860,10 +864,16 @@
860 # With JSON support
861 ifdef FOSSIL_ENABLE_JSON
862 TCC += -DFOSSIL_ENABLE_JSON=1
863 RCC += -DFOSSIL_ENABLE_JSON=1
864 endif
 
 
 
 
 
 
865
866 # With SQLite Encryption Extension support
867 ifdef USE_SEE
868 TCC += -DUSE_SEE=1
869 RCC += -DUSE_SEE=1
870
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -623,10 +623,14 @@
623 # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
624
625 #### Use 'system' SQLite
626 #
627 # USE_SYSTEM_SQLITE = 1
628
629 #### Use POSIX memory APIs from "sys/mman.h"
630 #
631 # USE_MMAN_H = 1
632
633 #### Use the SQLite Encryption Extension
634 #
635 # USE_SEE = 1
636
@@ -860,10 +864,16 @@
864 # With JSON support
865 ifdef FOSSIL_ENABLE_JSON
866 TCC += -DFOSSIL_ENABLE_JSON=1
867 RCC += -DFOSSIL_ENABLE_JSON=1
868 endif
869
870 # With "sys/mman.h" support
871 ifdef USE_MMAN_H
872 TCC += -DUSE_MMAN_H=1
873 RCC += -DUSE_MMAN_H=1
874 endif
875
876 # With SQLite Encryption Extension support
877 ifdef USE_SEE
878 TCC += -DUSE_SEE=1
879 RCC += -DUSE_SEE=1
880
--- src/th_main.c
+++ src/th_main.c
@@ -749,10 +749,11 @@
749749
** "tclPrivateStubs" = FOSSIL_ENABLE_TCL_PRIVATE_STUBS
750750
** "json" = FOSSIL_ENABLE_JSON
751751
** "markdown" = FOSSIL_ENABLE_MARKDOWN
752752
** "unicodeCmdLine" = !BROKEN_MINGW_CMDLINE
753753
** "dynamicBuild" = FOSSIL_DYNAMIC_BUILD
754
+** "mman" = USE_MMAN_H
754755
** "see" = USE_SEE
755756
**
756757
** Specifying an unknown feature will return a value of false, it will not
757758
** raise a script error.
758759
*/
@@ -829,10 +830,15 @@
829830
#endif
830831
#if defined(FOSSIL_DYNAMIC_BUILD)
831832
else if( 0 == fossil_strnicmp( zArg, "dynamicBuild\0", 13 ) ){
832833
rc = 1;
833834
}
835
+#endif
836
+#if defined(USE_MMAN_H)
837
+ else if( 0 == fossil_strnicmp( zArg, "mman\0", 5 ) ){
838
+ rc = 1;
839
+ }
834840
#endif
835841
#if defined(USE_SEE)
836842
else if( 0 == fossil_strnicmp( zArg, "see\0", 4 ) ){
837843
rc = 1;
838844
}
839845
--- src/th_main.c
+++ src/th_main.c
@@ -749,10 +749,11 @@
749 ** "tclPrivateStubs" = FOSSIL_ENABLE_TCL_PRIVATE_STUBS
750 ** "json" = FOSSIL_ENABLE_JSON
751 ** "markdown" = FOSSIL_ENABLE_MARKDOWN
752 ** "unicodeCmdLine" = !BROKEN_MINGW_CMDLINE
753 ** "dynamicBuild" = FOSSIL_DYNAMIC_BUILD
 
754 ** "see" = USE_SEE
755 **
756 ** Specifying an unknown feature will return a value of false, it will not
757 ** raise a script error.
758 */
@@ -829,10 +830,15 @@
829 #endif
830 #if defined(FOSSIL_DYNAMIC_BUILD)
831 else if( 0 == fossil_strnicmp( zArg, "dynamicBuild\0", 13 ) ){
832 rc = 1;
833 }
 
 
 
 
 
834 #endif
835 #if defined(USE_SEE)
836 else if( 0 == fossil_strnicmp( zArg, "see\0", 4 ) ){
837 rc = 1;
838 }
839
--- src/th_main.c
+++ src/th_main.c
@@ -749,10 +749,11 @@
749 ** "tclPrivateStubs" = FOSSIL_ENABLE_TCL_PRIVATE_STUBS
750 ** "json" = FOSSIL_ENABLE_JSON
751 ** "markdown" = FOSSIL_ENABLE_MARKDOWN
752 ** "unicodeCmdLine" = !BROKEN_MINGW_CMDLINE
753 ** "dynamicBuild" = FOSSIL_DYNAMIC_BUILD
754 ** "mman" = USE_MMAN_H
755 ** "see" = USE_SEE
756 **
757 ** Specifying an unknown feature will return a value of false, it will not
758 ** raise a script error.
759 */
@@ -829,10 +830,15 @@
830 #endif
831 #if defined(FOSSIL_DYNAMIC_BUILD)
832 else if( 0 == fossil_strnicmp( zArg, "dynamicBuild\0", 13 ) ){
833 rc = 1;
834 }
835 #endif
836 #if defined(USE_MMAN_H)
837 else if( 0 == fossil_strnicmp( zArg, "mman\0", 5 ) ){
838 rc = 1;
839 }
840 #endif
841 #if defined(USE_SEE)
842 else if( 0 == fossil_strnicmp( zArg, "see\0", 4 ) ){
843 rc = 1;
844 }
845
+21
--- src/util.c
+++ src/util.c
@@ -17,10 +17,14 @@
1717
**
1818
** This file contains code for miscellaneous utility routines.
1919
*/
2020
#include "config.h"
2121
#include "util.h"
22
+#if defined(USE_MMAN_H)
23
+# include <sys/mman.h>
24
+# include <unistd.h>
25
+#endif
2226
2327
/*
2428
** For the fossil_timer_xxx() family of functions...
2529
*/
2630
#ifdef _WIN32
@@ -72,10 +76,12 @@
7276
#if defined(_WIN32)
7377
SYSTEM_INFO sysInfo;
7478
memset(&sysInfo, 0, sizeof(SYSTEM_INFO));
7579
GetSystemInfo(&sysInfo);
7680
*piPageSize = (size_t)sysInfo.dwPageSize;
81
+#elif defined(USE_MMAN_H)
82
+ *piPageSize = (size_t)sysconf(_SC_PAGE_SIZE);
7783
#else
7884
*piPageSize = 4096; /* FIXME: What for POSIX? */
7985
#endif
8086
}
8187
void *fossil_secure_alloc_page(size_t *pN){
@@ -91,10 +97,18 @@
9197
fossil_fatal("VirtualAlloc failed: %lu\n", GetLastError());
9298
}
9399
if( !VirtualLock(p, pageSize) ){
94100
fossil_fatal("VirtualLock failed: %lu\n", GetLastError());
95101
}
102
+#elif defined(USE_MMAN_H)
103
+ p = mmap(0, pageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
104
+ if( p==MAP_FAILED ){
105
+ fossil_fatal("mmap failed: %d\n", errno);
106
+ }
107
+ if( mlock(p, pageSize) ){
108
+ fossil_fatal("mlock failed: %d\n", errno);
109
+ }
96110
#else
97111
p = fossil_malloc(pageSize);
98112
#endif
99113
fossil_secure_zero(p, pageSize);
100114
if( pN ) *pN = pageSize;
@@ -109,10 +123,17 @@
109123
fossil_fatal("VirtualUnlock failed: %lu\n", GetLastError());
110124
}
111125
if( !VirtualFree(p, 0, MEM_RELEASE) ){
112126
fossil_fatal("VirtualFree failed: %lu\n", GetLastError());
113127
}
128
+#elif defined(USE_MMAN_H)
129
+ if( munlock(p, n) ){
130
+ fossil_fatal("munlock failed: %d\n", errno);
131
+ }
132
+ if( munmap(p, n) ){
133
+ fossil_fatal("munmap failed: %d\n", errno);
134
+ }
114135
#else
115136
fossil_free(p);
116137
#endif
117138
}
118139
119140
--- src/util.c
+++ src/util.c
@@ -17,10 +17,14 @@
17 **
18 ** This file contains code for miscellaneous utility routines.
19 */
20 #include "config.h"
21 #include "util.h"
 
 
 
 
22
23 /*
24 ** For the fossil_timer_xxx() family of functions...
25 */
26 #ifdef _WIN32
@@ -72,10 +76,12 @@
72 #if defined(_WIN32)
73 SYSTEM_INFO sysInfo;
74 memset(&sysInfo, 0, sizeof(SYSTEM_INFO));
75 GetSystemInfo(&sysInfo);
76 *piPageSize = (size_t)sysInfo.dwPageSize;
 
 
77 #else
78 *piPageSize = 4096; /* FIXME: What for POSIX? */
79 #endif
80 }
81 void *fossil_secure_alloc_page(size_t *pN){
@@ -91,10 +97,18 @@
91 fossil_fatal("VirtualAlloc failed: %lu\n", GetLastError());
92 }
93 if( !VirtualLock(p, pageSize) ){
94 fossil_fatal("VirtualLock failed: %lu\n", GetLastError());
95 }
 
 
 
 
 
 
 
 
96 #else
97 p = fossil_malloc(pageSize);
98 #endif
99 fossil_secure_zero(p, pageSize);
100 if( pN ) *pN = pageSize;
@@ -109,10 +123,17 @@
109 fossil_fatal("VirtualUnlock failed: %lu\n", GetLastError());
110 }
111 if( !VirtualFree(p, 0, MEM_RELEASE) ){
112 fossil_fatal("VirtualFree failed: %lu\n", GetLastError());
113 }
 
 
 
 
 
 
 
114 #else
115 fossil_free(p);
116 #endif
117 }
118
119
--- src/util.c
+++ src/util.c
@@ -17,10 +17,14 @@
17 **
18 ** This file contains code for miscellaneous utility routines.
19 */
20 #include "config.h"
21 #include "util.h"
22 #if defined(USE_MMAN_H)
23 # include <sys/mman.h>
24 # include <unistd.h>
25 #endif
26
27 /*
28 ** For the fossil_timer_xxx() family of functions...
29 */
30 #ifdef _WIN32
@@ -72,10 +76,12 @@
76 #if defined(_WIN32)
77 SYSTEM_INFO sysInfo;
78 memset(&sysInfo, 0, sizeof(SYSTEM_INFO));
79 GetSystemInfo(&sysInfo);
80 *piPageSize = (size_t)sysInfo.dwPageSize;
81 #elif defined(USE_MMAN_H)
82 *piPageSize = (size_t)sysconf(_SC_PAGE_SIZE);
83 #else
84 *piPageSize = 4096; /* FIXME: What for POSIX? */
85 #endif
86 }
87 void *fossil_secure_alloc_page(size_t *pN){
@@ -91,10 +97,18 @@
97 fossil_fatal("VirtualAlloc failed: %lu\n", GetLastError());
98 }
99 if( !VirtualLock(p, pageSize) ){
100 fossil_fatal("VirtualLock failed: %lu\n", GetLastError());
101 }
102 #elif defined(USE_MMAN_H)
103 p = mmap(0, pageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
104 if( p==MAP_FAILED ){
105 fossil_fatal("mmap failed: %d\n", errno);
106 }
107 if( mlock(p, pageSize) ){
108 fossil_fatal("mlock failed: %d\n", errno);
109 }
110 #else
111 p = fossil_malloc(pageSize);
112 #endif
113 fossil_secure_zero(p, pageSize);
114 if( pN ) *pN = pageSize;
@@ -109,10 +123,17 @@
123 fossil_fatal("VirtualUnlock failed: %lu\n", GetLastError());
124 }
125 if( !VirtualFree(p, 0, MEM_RELEASE) ){
126 fossil_fatal("VirtualFree failed: %lu\n", GetLastError());
127 }
128 #elif defined(USE_MMAN_H)
129 if( munlock(p, n) ){
130 fossil_fatal("munlock failed: %d\n", errno);
131 }
132 if( munmap(p, n) ){
133 fossil_fatal("munmap failed: %d\n", errno);
134 }
135 #else
136 fossil_free(p);
137 #endif
138 }
139
140
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -96,10 +96,14 @@
9696
# FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
9797
9898
#### Use 'system' SQLite
9999
#
100100
# USE_SYSTEM_SQLITE = 1
101
+
102
+#### Use POSIX memory APIs from "sys/mman.h"
103
+#
104
+# USE_MMAN_H = 1
101105
102106
#### Use the SQLite Encryption Extension
103107
#
104108
# USE_SEE = 1
105109
@@ -333,10 +337,16 @@
333337
# With JSON support
334338
ifdef FOSSIL_ENABLE_JSON
335339
TCC += -DFOSSIL_ENABLE_JSON=1
336340
RCC += -DFOSSIL_ENABLE_JSON=1
337341
endif
342
+
343
+# With "sys/mman.h" support
344
+ifdef USE_MMAN_H
345
+TCC += -DUSE_MMAN_H=1
346
+RCC += -DUSE_MMAN_H=1
347
+endif
338348
339349
# With SQLite Encryption Extension support
340350
ifdef USE_SEE
341351
TCC += -DUSE_SEE=1
342352
RCC += -DUSE_SEE=1
343353
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -96,10 +96,14 @@
96 # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
97
98 #### Use 'system' SQLite
99 #
100 # USE_SYSTEM_SQLITE = 1
 
 
 
 
101
102 #### Use the SQLite Encryption Extension
103 #
104 # USE_SEE = 1
105
@@ -333,10 +337,16 @@
333 # With JSON support
334 ifdef FOSSIL_ENABLE_JSON
335 TCC += -DFOSSIL_ENABLE_JSON=1
336 RCC += -DFOSSIL_ENABLE_JSON=1
337 endif
 
 
 
 
 
 
338
339 # With SQLite Encryption Extension support
340 ifdef USE_SEE
341 TCC += -DUSE_SEE=1
342 RCC += -DUSE_SEE=1
343
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -96,10 +96,14 @@
96 # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
97
98 #### Use 'system' SQLite
99 #
100 # USE_SYSTEM_SQLITE = 1
101
102 #### Use POSIX memory APIs from "sys/mman.h"
103 #
104 # USE_MMAN_H = 1
105
106 #### Use the SQLite Encryption Extension
107 #
108 # USE_SEE = 1
109
@@ -333,10 +337,16 @@
337 # With JSON support
338 ifdef FOSSIL_ENABLE_JSON
339 TCC += -DFOSSIL_ENABLE_JSON=1
340 RCC += -DFOSSIL_ENABLE_JSON=1
341 endif
342
343 # With "sys/mman.h" support
344 ifdef USE_MMAN_H
345 TCC += -DUSE_MMAN_H=1
346 RCC += -DUSE_MMAN_H=1
347 endif
348
349 # With SQLite Encryption Extension support
350 ifdef USE_SEE
351 TCC += -DUSE_SEE=1
352 RCC += -DUSE_SEE=1
353
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -96,10 +96,14 @@
9696
FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
9797
9898
#### Use 'system' SQLite
9999
#
100100
# USE_SYSTEM_SQLITE = 1
101
+
102
+#### Use POSIX memory APIs from "sys/mman.h"
103
+#
104
+# USE_MMAN_H = 1
101105
102106
#### Use the SQLite Encryption Extension
103107
#
104108
# USE_SEE = 1
105109
@@ -333,10 +337,16 @@
333337
# With JSON support
334338
ifdef FOSSIL_ENABLE_JSON
335339
TCC += -DFOSSIL_ENABLE_JSON=1
336340
RCC += -DFOSSIL_ENABLE_JSON=1
337341
endif
342
+
343
+# With "sys/mman.h" support
344
+ifdef USE_MMAN_H
345
+TCC += -DUSE_MMAN_H=1
346
+RCC += -DUSE_MMAN_H=1
347
+endif
338348
339349
# With SQLite Encryption Extension support
340350
ifdef USE_SEE
341351
TCC += -DUSE_SEE=1
342352
RCC += -DUSE_SEE=1
343353
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -96,10 +96,14 @@
96 FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
97
98 #### Use 'system' SQLite
99 #
100 # USE_SYSTEM_SQLITE = 1
 
 
 
 
101
102 #### Use the SQLite Encryption Extension
103 #
104 # USE_SEE = 1
105
@@ -333,10 +337,16 @@
333 # With JSON support
334 ifdef FOSSIL_ENABLE_JSON
335 TCC += -DFOSSIL_ENABLE_JSON=1
336 RCC += -DFOSSIL_ENABLE_JSON=1
337 endif
 
 
 
 
 
 
338
339 # With SQLite Encryption Extension support
340 ifdef USE_SEE
341 TCC += -DUSE_SEE=1
342 RCC += -DUSE_SEE=1
343
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -96,10 +96,14 @@
96 FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1
97
98 #### Use 'system' SQLite
99 #
100 # USE_SYSTEM_SQLITE = 1
101
102 #### Use POSIX memory APIs from "sys/mman.h"
103 #
104 # USE_MMAN_H = 1
105
106 #### Use the SQLite Encryption Extension
107 #
108 # USE_SEE = 1
109
@@ -333,10 +337,16 @@
337 # With JSON support
338 ifdef FOSSIL_ENABLE_JSON
339 TCC += -DFOSSIL_ENABLE_JSON=1
340 RCC += -DFOSSIL_ENABLE_JSON=1
341 endif
342
343 # With "sys/mman.h" support
344 ifdef USE_MMAN_H
345 TCC += -DUSE_MMAN_H=1
346 RCC += -DUSE_MMAN_H=1
347 endif
348
349 # With SQLite Encryption Extension support
350 ifdef USE_SEE
351 TCC += -DUSE_SEE=1
352 RCC += -DUSE_SEE=1
353
--- win/fossil.rc
+++ win/fossil.rc
@@ -161,10 +161,15 @@
161161
#endif /* defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS) */
162162
#endif /* defined(FOSSIL_ENABLE_TCL) */
163163
#if defined(FOSSIL_ENABLE_JSON)
164164
VALUE "JsonEnabled", "Yes, cson " FOSSIL_JSON_API_VERSION "\0"
165165
#endif /* defined(FOSSIL_ENABLE_JSON) */
166
+#if defined(USE_MMAN_H)
167
+ VALUE "UseMmanEnabled", "Yes\0"
168
+#else
169
+ VALUE "UseMmanEnabled", "No\0"
170
+#endif /* defined(USE_MMAN_H) */
166171
#if defined(USE_SEE)
167172
VALUE "UseSeeEnabled", "Yes\0"
168173
#else
169174
VALUE "UseSeeEnabled", "No\0"
170175
#endif /* defined(USE_SEE) */
171176
--- win/fossil.rc
+++ win/fossil.rc
@@ -161,10 +161,15 @@
161 #endif /* defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS) */
162 #endif /* defined(FOSSIL_ENABLE_TCL) */
163 #if defined(FOSSIL_ENABLE_JSON)
164 VALUE "JsonEnabled", "Yes, cson " FOSSIL_JSON_API_VERSION "\0"
165 #endif /* defined(FOSSIL_ENABLE_JSON) */
 
 
 
 
 
166 #if defined(USE_SEE)
167 VALUE "UseSeeEnabled", "Yes\0"
168 #else
169 VALUE "UseSeeEnabled", "No\0"
170 #endif /* defined(USE_SEE) */
171
--- win/fossil.rc
+++ win/fossil.rc
@@ -161,10 +161,15 @@
161 #endif /* defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS) */
162 #endif /* defined(FOSSIL_ENABLE_TCL) */
163 #if defined(FOSSIL_ENABLE_JSON)
164 VALUE "JsonEnabled", "Yes, cson " FOSSIL_JSON_API_VERSION "\0"
165 #endif /* defined(FOSSIL_ENABLE_JSON) */
166 #if defined(USE_MMAN_H)
167 VALUE "UseMmanEnabled", "Yes\0"
168 #else
169 VALUE "UseMmanEnabled", "No\0"
170 #endif /* defined(USE_MMAN_H) */
171 #if defined(USE_SEE)
172 VALUE "UseSeeEnabled", "Yes\0"
173 #else
174 VALUE "UseSeeEnabled", "No\0"
175 #endif /* defined(USE_SEE) */
176
+1
--- www/th1.md
+++ www/th1.md
@@ -345,10 +345,11 @@
345345
1. **tclPrivateStubs** -- _Uses Tcl private stubs (i.e. header-only)._
346346
1. **json** -- _Support for the JSON APIs._
347347
1. **markdown** -- _Support for Markdown documentation format._
348348
1. **unicodeCmdLine** -- _The command line arguments are Unicode._
349349
1. **dynamicBuild** -- _Dynamically linked to libraries._
350
+ 1. **mman** -- _Uses POSIX memory APIs from "sys/mman.h"._
350351
1. **see** -- _Uses the SQLite Encryption Extension._
351352
352353
Specifying an unknown feature will return a value of false, it will not
353354
raise a script error.
354355
355356
--- www/th1.md
+++ www/th1.md
@@ -345,10 +345,11 @@
345 1. **tclPrivateStubs** -- _Uses Tcl private stubs (i.e. header-only)._
346 1. **json** -- _Support for the JSON APIs._
347 1. **markdown** -- _Support for Markdown documentation format._
348 1. **unicodeCmdLine** -- _The command line arguments are Unicode._
349 1. **dynamicBuild** -- _Dynamically linked to libraries._
 
350 1. **see** -- _Uses the SQLite Encryption Extension._
351
352 Specifying an unknown feature will return a value of false, it will not
353 raise a script error.
354
355
--- www/th1.md
+++ www/th1.md
@@ -345,10 +345,11 @@
345 1. **tclPrivateStubs** -- _Uses Tcl private stubs (i.e. header-only)._
346 1. **json** -- _Support for the JSON APIs._
347 1. **markdown** -- _Support for Markdown documentation format._
348 1. **unicodeCmdLine** -- _The command line arguments are Unicode._
349 1. **dynamicBuild** -- _Dynamically linked to libraries._
350 1. **mman** -- _Uses POSIX memory APIs from "sys/mman.h"._
351 1. **see** -- _Uses the SQLite Encryption Extension._
352
353 Specifying an unknown feature will return a value of false, it will not
354 raise a script error.
355
356

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button