You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,15 +82,27 @@ These can be added to your cmake command line.
82
82
-DUSE_MEASURE=ON // Measure performance with histograms
83
83
```
84
84
85
-
The project can be included in other CMake projects as a header
86
-
only library:
85
+
# Using snmalloc as header-only library
86
+
87
+
In this section we show how to compile snmalloc into your project such that it replaces the standard allocator functions such as free and malloc. The following instructions were tested with CMake and Clang running on Ubuntu 18.04.
88
+
89
+
Add these lines to your CMake file.
87
90
```
88
91
set(SNMALLOC_ONLY_HEADER_LIBRARY ON)
89
-
add_subdirectory([...]/snmalloc EXCLUDE_FROM_ALL)
92
+
add_subdirectory(snmalloc EXCLUDE_FROM_ALL)
93
+
```
94
+
95
+
In addition make sure your executable is compiled to support 128 bit atomic operations. This may require you to add the following to your CMake file.
You will also need to compile the relavent parts of snmalloc itself. Create a new file with the following contents and compile it with the rest of your application.
101
+
```
102
+
#define NO_BOOTSTRAP_ALLOCATOR
103
+
104
+
#include "snmalloc/src/override/malloc.cc"
90
105
```
91
-
This has a single build target `snmalloc_lib`, which includes
92
-
the necessary compiler and linker flags, to use snmalloc as a header-only
0 commit comments