diff options
-rw-r--r-- | regress/sys/uvm/Makefile | 4 | ||||
-rw-r--r-- | regress/sys/uvm/mmap_size/Makefile | 4 | ||||
-rw-r--r-- | regress/sys/uvm/mmap_size/mmap_size.c | 45 |
3 files changed, 51 insertions, 2 deletions
diff --git a/regress/sys/uvm/Makefile b/regress/sys/uvm/Makefile index 0ed3bea1629..58d25f717fc 100644 --- a/regress/sys/uvm/Makefile +++ b/regress/sys/uvm/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.2 2002/02/23 01:25:11 art Exp $ +# $OpenBSD: Makefile,v 1.3 2005/01/06 10:14:20 otto Exp $ -SUBDIR=misc +SUBDIR=misc mmap_size install: diff --git a/regress/sys/uvm/mmap_size/Makefile b/regress/sys/uvm/mmap_size/Makefile new file mode 100644 index 00000000000..2c5d809d386 --- /dev/null +++ b/regress/sys/uvm/mmap_size/Makefile @@ -0,0 +1,4 @@ +# $OpenBSD: Makefile,v 1.1 2005/01/06 10:14:20 otto Exp $ +PROG=mmap_size + +.include <bsd.regress.mk> diff --git a/regress/sys/uvm/mmap_size/mmap_size.c b/regress/sys/uvm/mmap_size/mmap_size.c new file mode 100644 index 00000000000..5bd9b0980f2 --- /dev/null +++ b/regress/sys/uvm/mmap_size/mmap_size.c @@ -0,0 +1,45 @@ +/* $OpenBSD: mmap_size.c,v 1.1 2005/01/06 10:14:20 otto Exp $ */ + +/* + * Public domain. 2005, Otto Moerbeek <otto@drijf.net> + */ + +#include <sys/types.h> +#include <sys/mman.h> +#include <err.h> +#include <limits.h> +#include <stdlib.h> +#include <stdio.h> + +void +f(size_t sz) +{ + char *p; + p = mmap(NULL, sz, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_PRIVATE, -1, (off_t)0); + + if (p == MAP_FAILED) + return; + + if (sz > 0) { + p[0] = 0; + p[sz / 2] = 0; + p[sz - 1] = 0; + } + munmap(p, sz); +} + +int +main() +{ + size_t i; + + for (i = 0; i < 0x2000; i += 0x100) { + f(i); + f(-i); + f(SIZE_T_MAX/2 - 0x1000); + } + return (0); +} + + |