def sys_mmap(self, address, size, prot, flags, fd, offset):
if address == <NUM_LIT:0>:<EOL><INDENT>address = None<EOL><DEDENT>cpu = self.current<EOL>if flags & <NUM_LIT>:<EOL><INDENT>cpu.memory.munmap(address, size)<EOL><DEDENT>perms = perms_from_protflags(prot)<EOL>if flags & <NUM_LIT>:<EOL><INDENT>result = cpu.memory.mmap(address, size, perms)<EOL><DEDENT>elif fd == <NUM_LIT:0>:<EOL><INDENT>assert offset == <NUM_LIT:0><EOL>result = cpu.memory.mmap(address, size, perms)<EOL>data = self.files[fd].read(size)<EOL>cpu.write_bytes(result, data)<EOL><DEDENT>else:<EOL><INDENT>result = cpu.memory.mmapFile(address, size, perms, self.files[fd].name, offset)<EOL><DEDENT>actually_mapped = f'<STR_LIT>'<EOL>if address is None or result != address:<EOL><INDENT>address = address or <NUM_LIT:0><EOL>actually_mapped += f'<STR_LIT>'<EOL><DEDENT>if flags & <NUM_LIT> != <NUM_LIT:0> and result != address:<EOL><INDENT>cpu.memory.munmap(result, size)<EOL>result = -<NUM_LIT:1><EOL><DEDENT>return result<EOL>
Creates a new mapping in the virtual address space of the calling process.
:rtype: int

:param address: the starting address for the new mapping. This address is used as hint unless the
                flag contains C{MAP_FIXED}.
:param size: the length of the mapping.
:param prot: the desired memory protection of the mapping.
:param flags: determines whether updates to the mapping are visible to other
              processes mapping the same region, and whether updates are carried
              through to the underlying file.
:param fd: the contents of a file mapping are initialized using C{size} bytes starting at
           offset C{offset} in the file referred to by the file descriptor C{fd}.
:param offset: the contents of a file mapping are initialized using C{size} bytes starting at
               offset C{offset} in the file referred to by the file descriptor C{fd}.
:return:
        - C{-1} in case you use C{MAP_FIXED} in the flags and the mapping can not be place at the desired address.
        - the address of the new mapping (that must be the same as address in case you included C{MAP_FIXED} in flags).
:todo: handle exception.