# PerlIO::mmap
๐Ÿ“ฆ min
Memory-mapped IO layer opened as `<:mmap`, with a read()/write() fallback when mmap fails. This is a PerlIO layer that memory-maps files for reading instead of using read() syscalls. It falls back to PerlIOBuf if mmap fails. The layer extends PerlIOBuf with: mptr โ€” mapped address (from mmap()) len โ€” mapped length bbuf โ€” saved malloced buffer if map fails The BOOT section registers the ยซmmapยป PerlIO layer via PerlIO_define_layer. `mmap.xs` vtable (PerlIO_mmap, lines 258-287): Pushed = PerlIOBuf_pushed โ€” line 263 Popped = PerlIOBuf_popped โ€” line 264 Open = PerlIOBuf_open โ€” line 265 Binmode = PerlIOBase_binmode โ€” line 266 Getarg = NULL โ€” line 267 Fileno = PerlIOBase_fileno โ€” line 268 Dup = PerlIOMmap_dup โ€” line 269 Read = PerlIOBuf_read โ€” line 270 Unread = PerlIOMmap_unread โ€” line 271 Write = PerlIOMmap_write โ€” line 272 Seek = PerlIOBuf_seek โ€” line 273 Tell = PerlIOBuf_tell โ€” line 274 Close = PerlIOBuf_close โ€” line 275 Flush = PerlIOMmap_flush โ€” line 276 Fill = PerlIOMmap_fill โ€” line 277 Eof = PerlIOBase_eof โ€” line 278 Error = PerlIOBase_error โ€” line 279 Clearerr = PerlIOBase_clearerr โ€” line 280 Setlinebuf = PerlIOBase_setlinebuf โ€” line 281 Get_base = PerlIOMmap_get_base โ€” line 282 Get_bufsiz = PerlIOBuf_bufsiz โ€” line 283 Get_ptr = PerlIOBuf_get_ptr โ€” line 284 Get_cnt = PerlIOBuf_get_cnt โ€” line 285 Set_ptrcnt = PerlIOBuf_set_ptrcnt โ€” line 286