Skip to content

Commit 4a4a76c

Browse files
Add page size system features
1 parent 2d9b213 commit 4a4a76c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libstore/globals.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#include <sys/sysctl.h>
3636
#endif
3737

38+
#ifdef __linux__
39+
#include <sys/auxv.h>
40+
#endif
41+
3842
#include "strings.hh"
3943

4044
namespace nix {
@@ -196,6 +200,16 @@ StringSet Settings::getDefaultSystemFeatures()
196200
features.insert("apple-virt");
197201
#endif
198202

203+
#if __linux__
204+
unsigned long pgsize = getauxval(AT_PAGESZ);
205+
#else
206+
unsigned long pgsize = getpagesize();
207+
#endif
208+
209+
for (; pgsize <= (64 * 1024); pgsize *= 2) {
210+
features.insert(fmt("pages-%1%k", pgsize / 1024));
211+
}
212+
199213
return features;
200214
}
201215

0 commit comments

Comments
 (0)