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,9 +7,12 @@ | ||
7 | #include "../math/vector.h" | 7 | #include "../math/vector.h" |
8 | #include <fstream> | 8 | #include <fstream> |
9 | #include <sys/stat.h> | 9 | #include <sys/stat.h> |
10 | +#include <cstring> | ||
10 | 11 | ||
11 | #ifdef _WIN32 | 12 | #ifdef _WIN32 |
12 | #include <Windows.h> | 13 | #include <Windows.h> |
14 | +#else | ||
15 | +#include <unistd.h> | ||
13 | #endif | 16 | #endif |
14 | 17 | ||
15 | namespace stim{ | 18 | namespace stim{ |
@@ -38,7 +41,7 @@ protected: | @@ -38,7 +41,7 @@ protected: | ||
38 | 41 | ||
39 | /// Private initialization function used to set default parameters in the data structure. | 42 | /// Private initialization function used to set default parameters in the data structure. |
40 | void init(){ | 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 | header = 0; //initialize the header size to zero | 45 | header = 0; //initialize the header size to zero |
43 | mask = NULL; | 46 | mask = NULL; |
44 | 47 | ||
@@ -131,6 +134,10 @@ public: | @@ -131,6 +134,10 @@ public: | ||
131 | statex.dwLength = sizeof (statex); | 134 | statex.dwLength = sizeof (statex); |
132 | GlobalMemoryStatusEx (&statex); | 135 | GlobalMemoryStatusEx (&statex); |
133 | buffer_size = (size_t)(statex.ullAvailPhys * mem_frac); | 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 | #endif | 141 | #endif |
135 | } | 142 | } |
136 | 143 |