Explicitly request literal mode after .Xr.
[netbsd-mini2440.git] / dist / nvi / clib / mmap.c
blob31c0ac614d56fbaf905083bd653384a5285950f7
1 /* $NetBSD$ */
3 #include "config.h"
5 #include <sys/types.h>
7 #include <stdlib.h>
8 #include <unistd.h>
11 * This function fakes mmap() by reading `len' bytes from the file descriptor
12 * `fd' and returning a pointer to that memory. The "mapped" region can later
13 * be deallocated with munmap().
15 * Note: ONLY reading is supported and only reading of the exact size of the
16 * file will work.
18 * PUBLIC: #ifndef HAVE_MMAP
19 * PUBLIC: char *mmap __P((char *, size_t, int, int, int, off_t));
20 * PUBLIC: #endif
22 char *
23 mmap(char *addr, size_t len, int prot, int flags, int fd, off_t off)
25 char *ptr;
27 if ((ptr = (char *)malloc(len)) == 0)
28 return ((char *)-1);
29 if (read(fd, ptr, len) < 0) {
30 free(ptr);
31 return ((char *)-1);
33 return (ptr);
37 * PUBLIC: #ifndef HAVE_MMAP
38 * PUBLIC: int munmap __P((char *, size_t));
39 * PUBLIC: #endif
41 int
42 munmap(char *addr, size_t len)
44 free(addr);
45 return (0);