summaryrefslogtreecommitdiff
path: root/regress/sys/uvm/mmap_fixed
diff options
context:
space:
mode:
Diffstat (limited to 'regress/sys/uvm/mmap_fixed')
-rw-r--r--regress/sys/uvm/mmap_fixed/Makefile4
-rw-r--r--regress/sys/uvm/mmap_fixed/mmap_fixed.c33
2 files changed, 37 insertions, 0 deletions
diff --git a/regress/sys/uvm/mmap_fixed/Makefile b/regress/sys/uvm/mmap_fixed/Makefile
new file mode 100644
index 00000000000..405f33cb805
--- /dev/null
+++ b/regress/sys/uvm/mmap_fixed/Makefile
@@ -0,0 +1,4 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2006/04/06 20:39:03 kurt Exp $
+PROG=mmap_fixed
+
+.include <bsd.regress.mk>
diff --git a/regress/sys/uvm/mmap_fixed/mmap_fixed.c b/regress/sys/uvm/mmap_fixed/mmap_fixed.c
new file mode 100644
index 00000000000..4b3669ba5da
--- /dev/null
+++ b/regress/sys/uvm/mmap_fixed/mmap_fixed.c
@@ -0,0 +1,33 @@
+/* $OpenBSD: mmap_fixed.c,v 1.1.1.1 2006/04/06 20:39:03 kurt Exp $ */
+
+/*
+ * Public domain. 2006, Kurt Miller <kurt@intricatesoftware.com>
+ */
+
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <err.h>
+
+#define MEM_SIZE 1024*1024
+
+/*
+ * Repetitively call mmap with MMAP_FIXED on the same region of memory
+ * to ensure process datasize is properly calculated.
+ */
+
+int
+main(void)
+{
+ void *mem_area;
+ int i;
+
+ mem_area = mmap(0, MEM_SIZE, PROT_NONE, MAP_ANON, -1, 0);
+
+ for (i = 0; i < 20000; i++) {
+ if (mmap(mem_area, MEM_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_ANON|MAP_FIXED, -1, 0) == MAP_FAILED)
+ err(1, NULL);
+ }
+
+ return (0);
+}