Fossil SCM

Experimental support for using 'mman.h' when compiling for POSIX.

mistachkin 2018-03-17 20:31 trunk
Commit 37b69e7d0cdc8fe4cc11dd0208b8deb9c606cf9d1e34e850bc399a1d002e862c
--- 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 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 \"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 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 \"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
+18
--- src/util.c
+++ src/util.c
@@ -17,10 +17,13 @@
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
+#endif
2225
2326
/*
2427
** For the fossil_timer_xxx() family of functions...
2528
*/
2629
#ifdef _WIN32
@@ -91,10 +94,18 @@
9194
fossil_fatal("VirtualAlloc failed: %lu\n", GetLastError());
9295
}
9396
if( !VirtualLock(p, pageSize) ){
9497
fossil_fatal("VirtualLock failed: %lu\n", GetLastError());
9598
}
99
+#elif defined(USE_MMAN_H)
100
+ p = mmap(0, pageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
101
+ if( p==MAP_FAILED ){
102
+ fossil_fatal("mmap failed: %d\n", errno);
103
+ }
104
+ if( mlock(p, pageSize) ){
105
+ fossil_fatal("mlock failed: %d\n", errno);
106
+ }
96107
#else
97108
p = fossil_malloc(pageSize);
98109
#endif
99110
fossil_secure_zero(p, pageSize);
100111
if( pN ) *pN = pageSize;
@@ -109,10 +120,17 @@
109120
fossil_fatal("VirtualUnlock failed: %lu\n", GetLastError());
110121
}
111122
if( !VirtualFree(p, 0, MEM_RELEASE) ){
112123
fossil_fatal("VirtualFree failed: %lu\n", GetLastError());
113124
}
125
+#elif defined(USE_MMAN_H)
126
+ if( munlock(p, n) ){
127
+ fossil_fatal("munlock failed: %d\n", errno);
128
+ }
129
+ if( munmap(p, n) ){
130
+ fossil_fatal("munmap failed: %d\n", errno);
131
+ }
114132
#else
115133
fossil_free(p);
116134
#endif
117135
}
118136
119137
--- src/util.c
+++ src/util.c
@@ -17,10 +17,13 @@
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
@@ -91,10 +94,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 +120,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,13 @@
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 #endif
25
26 /*
27 ** For the fossil_timer_xxx() family of functions...
28 */
29 #ifdef _WIN32
@@ -91,10 +94,18 @@
94 fossil_fatal("VirtualAlloc failed: %lu\n", GetLastError());
95 }
96 if( !VirtualLock(p, pageSize) ){
97 fossil_fatal("VirtualLock failed: %lu\n", GetLastError());
98 }
99 #elif defined(USE_MMAN_H)
100 p = mmap(0, pageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
101 if( p==MAP_FAILED ){
102 fossil_fatal("mmap failed: %d\n", errno);
103 }
104 if( mlock(p, pageSize) ){
105 fossil_fatal("mlock failed: %d\n", errno);
106 }
107 #else
108 p = fossil_malloc(pageSize);
109 #endif
110 fossil_secure_zero(p, pageSize);
111 if( pN ) *pN = pageSize;
@@ -109,10 +120,17 @@
120 fossil_fatal("VirtualUnlock failed: %lu\n", GetLastError());
121 }
122 if( !VirtualFree(p, 0, MEM_RELEASE) ){
123 fossil_fatal("VirtualFree failed: %lu\n", GetLastError());
124 }
125 #elif defined(USE_MMAN_H)
126 if( munlock(p, n) ){
127 fossil_fatal("munlock failed: %d\n", errno);
128 }
129 if( munmap(p, n) ){
130 fossil_fatal("munmap failed: %d\n", errno);
131 }
132 #else
133 fossil_free(p);
134 #endif
135 }
136
137

Keyboard Shortcuts

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