2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2015, Joyent, Inc.
17 * Verify that using MC_INHERIT_ZERO works just fine when applied to a subset of
18 * a region, meaning that we should have created a struct vpage for that region.
21 #include <sys/types.h>
38 size_t pgsz
= sysconf(_SC_PAGESIZE
);
39 size_t mapsz
= 10 * pgsz
;
40 size_t clrsz
= 5 * pgsz
;
41 size_t clroff
= 2 * pgsz
;
43 buf
= mmap(NULL
, mapsz
, PROT_READ
| PROT_WRITE
,
44 MAP_PRIVATE
| MAP_ANON
, -1, 0);
45 assert(buf
!= MAP_FAILED
);
46 memset(buf
, 'a', mapsz
);
48 ret
= memcntl(buf
+ clroff
, clrsz
, MC_INHERIT_ZERO
, 0, 0, 0);
54 for (i
= 0; i
< clroff
; i
++)
55 assert(ubuf
[i
] == 'a');
56 for (i
= clroff
; i
< clrsz
+ clroff
; i
++)
58 for (i
= clrsz
+ clroff
; i
< mapsz
; i
++)
59 assert(ubuf
[i
] == 'a');
65 ret
= waitid(P_PID
, child
, &info
, WEXITED
);
66 } while (ret
== -1 && errno
== EINTR
);
68 assert(info
.si_pid
== child
);
69 assert(info
.si_status
== 0);
71 for (i
= 0, ubuf
= buf
; i
< mapsz
; i
++)
72 assert(ubuf
[i
] == 'a');