2 * Sherlock Library -- Mapping of Files
4 * (c) 1999 Martin Mares <mj@ucw.cz>
16 #warning System includes do not define MAP_FAILED.
17 #define MAP_FAILED ((void *)-1L)
21 mmap_file(byte *name, unsigned *len, int writeable)
23 int fd = open(name, writeable ? O_RDWR : O_RDONLY);
29 if (fstat(fd, &st) < 0)
37 x = mmap(NULL, st.st_size, writeable ? (PROT_READ | PROT_WRITE) : PROT_READ, MAP_SHARED, fd, 0);
41 else /* For empty file, we can return any non-zero address */
49 munmap_file(void *start, unsigned len)