Commit 15a3176396c755eff28507083fff9dd4e7fe3313
1 parent
5e1b4869
set up buffer estimation for Linux
Showing
1 changed file
with
8 additions
and
1 deletions
Show diff stats
stim/envi/binary.h
... | ... | @@ -7,9 +7,12 @@ |
7 | 7 | #include "../math/vector.h" |
8 | 8 | #include <fstream> |
9 | 9 | #include <sys/stat.h> |
10 | +#include <cstring> | |
10 | 11 | |
11 | 12 | #ifdef _WIN32 |
12 | 13 | #include <Windows.h> |
14 | +#else | |
15 | +#include <unistd.h> | |
13 | 16 | #endif |
14 | 17 | |
15 | 18 | namespace stim{ |
... | ... | @@ -38,7 +41,7 @@ protected: |
38 | 41 | |
39 | 42 | /// Private initialization function used to set default parameters in the data structure. |
40 | 43 | void init(){ |
41 | - memset(R, 0, sizeof(unsigned long long) * D); //initialize the resolution to zero | |
44 | + std::memset(R, 0, sizeof(unsigned long long) * D); //initialize the resolution to zero | |
42 | 45 | header = 0; //initialize the header size to zero |
43 | 46 | mask = NULL; |
44 | 47 | |
... | ... | @@ -131,6 +134,10 @@ public: |
131 | 134 | statex.dwLength = sizeof (statex); |
132 | 135 | GlobalMemoryStatusEx (&statex); |
133 | 136 | buffer_size = (size_t)(statex.ullAvailPhys * mem_frac); |
137 | +#else | |
138 | + size_t pages = sysconf(_SC_PHYS_PAGES); | |
139 | + size_t page_size = sysconf(_SC_PAGE_SIZE); | |
140 | + buffer_size = (size_t)(pages * page_size * mem_frac); | |
134 | 141 | #endif |
135 | 142 | } |
136 | 143 | ... | ... |