summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2004-06-18 15:30:25 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2004-06-18 15:30:25 +0000
commit5d87550ba704a2da711703a4ee106b967b7858c0 (patch)
tree090153da6a4c8b11697d8c2c53cc89b3945dbac2
parent5b433a5de9c81f1ab872f5732299b5e3573cc220 (diff)
downloadbcm5719-llvm-5d87550ba704a2da711703a4ee106b967b7858c0.tar.gz
bcm5719-llvm-5d87550ba704a2da711703a4ee106b967b7858c0.zip
Add a target-independent way to query page size.
llvm-svn: 14232
-rw-r--r--llvm/include/Config/pagesize.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/llvm/include/Config/pagesize.h b/llvm/include/Config/pagesize.h
new file mode 100644
index 00000000000..638ece03288
--- /dev/null
+++ b/llvm/include/Config/pagesize.h
@@ -0,0 +1,49 @@
+/*
+ * The LLVM Compiler Infrastructure
+ *
+ * This file was developed by the LLVM research group and is distributed under
+ * the University of Illinois Open Source License. See LICENSE.TXT for details.
+ *
+ ******************************************************************************
+ *
+ * This header file provides a platform-independent way of quering page size.
+ */
+
+#ifndef PAGESIZE_H
+#define PAGESIZE_H
+
+#include "Config/unistd.h"
+#include <sys/param.h>
+
+namespace llvm {
+
+/* Compatibility chart:
+ *
+ * x86/Linux: _SC_PAGESIZE, _SC_PAGE_SIZE
+ * MacOS X/PowerPC: v. 10.2: NBPG,
+ * v. 10.3: _SC_PAGESIZE
+ * Solaris/Sparc: _SC_PAGESIZE, _SC_PAGE_SIZE
+ */
+
+/**
+ * GetPageSize - wrapper to return page size in bytes for various
+ * architecture/OS combinations
+ */
+unsigned GetPageSize() {
+#ifdef _SC_PAGESIZE
+ return sysconf(_SC_PAGESIZE);
+#elif defined(_SC_PAGE_SIZE)
+ return sysconf(_SC_PAGE_SIZE);
+#elif defined(NBPG)
+#ifndef CLSIZE
+#define CLSIZE 1
+#endif
+ return NBPG * CLSIZE;
+#else
+ return 4096; /* allocate 4KB as a fall-back */
+#endif
+}
+
+}
+
+#endif
OpenPOWER on IntegriCloud