1 <assertions> 2 <assertion id="1" tag="ref:XSH6:25180:25190"> 3 mmap( ) function shall establish a mapping between the address space of 4 the process at an address pa for len bytes to the memory object represented 5 by the file descriptor fildes at offset off for len bytes. 6 </assertion> 7 8 <assertion id="2" tag="ref:XSH6:25191:25196"> 9 If fildes represents a typed memory object opened with either the 10 POSIX_TYPED_MEM_ALLOCATE flag or the POSIX_TYPED_MEM_ALLOCATE_CONTIG 11 flag, the memory object to be mapped shall be that portion of the typed memory object allocated. 12 </assertion> 13 14 <assertion id="3" tag="ref:XSH6:25197:25199"> 15 mapping established by mmap( ) shall replace any previous mappings for 16 those whole pages containing any part of the address space. 17 </assertion> 18 19 <assertion id="4" tag="ref:XSH6:25203:25204"> 20 TYM The mmap( ) function shall be supported for regular files, shared memory objects, and typed 21 memory objects. Support for any other type of file is unspecified. 22 </assertion> 23 24 <assertion id="5" tag="ref:XSH6:25206:25216"> 25 The prot shall be either PROT_NONE or the bitwise- 26 inclusive OR of one or more of the other flags in the following table 27 PROT_READ Data can be read. 28 PROT_WRITE Data can be written. 29 PROT_EXEC Data can be executed. 30 PROT_NONE Data cannot be accessed. 31 </assertion> 32 33 <assertion id="6" tag="ref:XSH6:25217:25226"> 34 An implementation may permit accesses other than those specified by prot; however, if the 35 Memory Protection option is supported, the implementation shall not permit a write to succeed 36 where PROT_WRITE has not been set or shall not permit any access where PROT_NONE alone 37 has been set. The implementation shall support at least the following values of prot: 38 PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of PROT_READ and 39 PROT_WRITE. If the Memory Protection option is not supported, the result of any access that 40 conflicts with the specified protection is undefined. The file descriptor fildes shall have been 41 opened with read permission, regardless of the protection options specified. If PROT_WRITE is 42 specified, the application shall ensure that it has opened the file descriptor fildes with write 43 permission unless MAP_PRIVATE is specified in the flags parameter as described below. 44 </assertion> 45 46 <assertion id="7" tag="ref:XSH6:25236:25244"> 47 It is implementation-defined whether MAP_FIXED shall be supported. MAP_FIXED shall be 48 supported on XSI-conformant systems. 49 MAP_SHARED and MAP_PRIVATE describe the disposition of write references to the memory 50 object. If MAP_SHARED is specified, write references shall change the underlying object. If 51 MAP_PRIVATE is specified, modifications to the mapped data by the calling process shall be 52 visible only to the calling process and shall not change the underlying object. It is unspecified 53 whether modifications to the underlying object done after the MAP_PRIVATE mapping is 54 established are visible through the MAP_PRIVATE mapping. Either MAP_SHARED or 55 MAP_PRIVATE can be specified, but not both. The mapping type is retained across fork( ). 56 </assertion> 57 58 <assertion id="8" tag="ref:XSH6:25245:25260"> 59 When fildes represents a typed memory object opened with either the 60 POSIX_TYPED_MEM_ALLOCATE flag or the POSIX_TYPED_MEM_ALLOCATE_CONTIG 61 flag, mmap( ) shall, if there are enough resources available, map len bytes allocated from the 62 corresponding typed memory object which were not previously allocated to any process in any 63 processor that may access that typed memory object. 64 </assertion> 65 66 <assertion id="9" tag="ref:XSH6:25261:25264"> 67 When MAP_FIXED is set in the flags argument, the implementation is informed that the value of 68 pa shall be addr, exactly. If MAP_FIXED is set, mmap( ) may returnMAP_FAILED and set errno to 69 [EINVAL]. If a MAP_FIXED request is successful, the mapping established by mmap( ) replaces 70 any previous mappings for the process' pages in the range [pa,pa+len). 71 </assertion> 72 73 <assertion id="10" tag="ref:XSH6:25265:25271"> 74 When MAP_FIXED is not set, the implementation uses addr in an implementation-defined 75 manner to arrive at pa. The pa so chosen shall be an area of the address space that the 76 implementation deems suitable for a mapping of len bytes to the file. All implementations 77 interpret an addr value of 0 as granting the implementation complete freedom in selecting pa, 78 subject to constraints described below. A non-zero value of addr is taken to be a suggestion of a 79 process address near which the mapping should be placed. When the implementation selects a 80 value for pa, it never places a mapping at address 0, nor does it replace any extant mapping. 81 </assertion> 82 83 <assertion id="11" tag="ref:XSH6:25272:25281"> 84 The off argument is constrained to be aligned and sized according to the value returned by 85 sysconf( ) when passed _SC_PAGESIZE or _SC_PAGE_SIZE. When MAP_FIXED is specified, the 86 application shall ensure that the argument addr also meets these constraints. The 87 implementation performs mapping operations over whole pages. Thus, while the argument len 88 need not meet a size or alignment constraint, the implementation shall include, in any mapping 89 operation, any partial page specified by the range [pa,pa+len). 90 The system shall always zero-fill any partial page at the end of an object. Further, the system 91 shall never write out any modified portions of the last page of an object which are beyond its 92 MPR end. References within the address range starting at pa and continuing for len bytes to whole 93 pages following the end of an object shall result in delivery of a SIGBUS signal. 94 </assertion> 95 96 <assertion id="12" tag="ref:XSH6:25284:25286"> 97 The mmap( ) function shall add an extra reference to the file associated with the file descriptor 98 fildes which is not removed by a subsequent close( ) on that file descriptor. This reference shall be 99 removed when there are no more mappings to the file. 100 </assertion> 101 102 <assertion id="13" tag="ref:XSH6:25287:25290"> 103 The st_atime field of the mapped file may be marked for update at any time between the mmap( ) 104 call and the corresponding munmap( ) call. The initial read or write reference to a mapped region 105 shall cause the file's st_atime field to be marked for update if it has not already been marked for 106 update. 107 </assertion> 108 109 <assertion id="14" tag="ref:XSH6:25291:25296"> 110 The st_ctime and st_mtime fields of a file that is mapped with MAP_SHARED and PROT_WRITE 111 shall be marked for update at some point in the interval between a write reference to the 112 mapped region and the next call to msync( ) with MS_ASYNC or MS_SYNC for that portion of 113 the file by any process. 114 </assertion> 115 116 <assertion id="15" tag="ref:XSH6:25301:25303"> 117 If mmap( ) fails for reasons other than [EBADF], [EINVAL], or [ENOTSUP], some of the 118 mappings in the address range starting at addr and continuing for len bytes may have been 119 unmapped. 120 </assertion> 121 122 123 <assertion id="16" tag="ref:XSH6:25305:25308"> 124 Upon successful completion, the mmap( ) function shall return the address at which the mapping 125 was placed (pa); otherwise, it shall return a value of MAP_FAILED and set errno to indicate the 126 error. The symbol MAP_FAILED is defined in the sys/mman.h header. No successful return 127 from mmap( ) shall return the value MAP_FAILED. 128 </assertion> 129 130 <assertion id="17" tag="ref:XSH6:25310:25342"> 131 The mmap( ) function shall fail if: 132 [EACCES] The fildes argument is not open for read, regardless of the protection specified, 133 or fildes is not open for write and PROT_WRITE was specified for a 134 MAP_SHARED type mapping. 135 </assertion> 136 137 <assertion id="18" tag="ref:XSH6:25310:25315"> 138 The mmap( ) function shall fail if: 139 ML [EAGAIN] The mapping could not be locked in memory, if required by mlockall ( ), due to 140 a lack of resources. 141 </assertion> 142 143 <assertion id="19" tag="ref:XSH6:25310:25342"> 144 The mmap( ) function shall fail if: 145 [EBADF] The fildes argument is not a valid open file descriptor. 146 </assertion> 147 148 <assertion id="20" tag="ref:XSH6:25310:25342"> 149 The mmap( ) function shall fail if: 150 [EINVAL] The addr argument (if MAP_FIXED was specified) or off is not a multiple of 151 the page size as returned by sysconf( ), or is considered invalid by the 152 implementation. 153 </assertion> 154 155 <assertion id="21" tag="ref:XSH6:25310:25342"> 156 The mmap( ) function shall fail if: 157 [EINVAL] The value of flags is invalid (neither MAP_PRIVATE nor MAP_SHARED is 158 set). 159 </assertion> 160 161 <assertion id="22" tag="ref:XSH6:25310:25342"> 162 The mmap( ) function shall fail if: 163 [EMFILE] The number of mapped regions would exceed an implementation-defined 164 limit (per process or per system). 165 </assertion> 166 167 <assertion id="23" tag="ref:XSH6:25310:25342"> 168 The mmap( ) function shall fail if: 169 [ENODEV] The fildes argument refers to a file whose type is not supported by mmap( ). 170 </assertion> 171 172 <assertion id="24" tag="ref:XSH6:25310:25342"> 173 The mmap( ) function shall fail if: 174 [ENOMEM] MAP_FIXED was specified, and the range [addr,addr+len) exceeds that allowed 175 for the address space of a process; or, if MAP_FIXED was not specified and 176 there is insufficient room in the address space to effect the mapping. 177 </assertion> 178 179 <assertion id="25" tag="ref:XSH6:25310:25342"> 180 mmap( ) function shall fail if: 181 [ENOMEM] The mapping could not be locked in memory, if required by mlockall ( ), 182 because it would require more space than the system is able to supply. 183 </assertion> 184 185 <assertion id="26" tag="ref:XSH6:25310:25342"> 186 The mmap( ) function shall fail if: 187 [ENOMEM] Not enough unallocated memory resources remain in the typed memory 188 object designated by fildes to allocate len bytes. 189 </assertion> 190 191 <assertion id="27" tag="ref:XSH6:25310:25342"> 192 The mmap( ) function shall fail if: 193 [ENOTSUP] MAP_FIXED or MAP_PRIVATE was specified in the flags argument and the 194 implementation does not support this functionality. 195 The implementation does not support the combination of accesses requested 196 in the prot argument. 197 </assertion> 198 199 <assertion id="28" tag="ref:XSH6:25310:25342"> 200 The mmap( ) function shall fail if: 201 [ENXIO] Addresses in the range [off,off+len) are invalid for the object specified by fildes. 202 </assertion> 203 204 <assertion id="29" tag="ref:XSH6:25310:25342"> 205 The mmap( ) function shall fail if: 206 [ENXIO] MAP_FIXED was specified in flags and the combination of addr, len, and off is 207 invalid for the object specified by fildes. 208 </assertion> 209 210 <assertion id="30" tag="ref:XSH6:25310:25342"> 211 The mmap( ) function shall fail if: 212 [ENXIO] The fildes argument refers to a typed memory object that is not accessible from 213 the calling process. 214 </assertion> 215 216 <assertion id="31" tag="ref:XSH6:25310:25342"> 217 The mmap( ) function shall fail if: 218 [EOVERFLOW] The file is a regular file and the value of off plus len exceeds the offset 219 maximum established in the open file description associated with fildes. 220 </assertion> 221 222 <assertion id="32"> 223 [EINVAL] The value of len is zero. 224 <assertion> 225 </assertions> 226 227