1 /* Copyright (C) 1989- 2014 Free Software Foundation, Inc.
2 Written by James Clark (jjc@jclark.com)
4 This file is part of groff.
6 groff is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 groff is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 #include <sys/types.h>
30 /* The Net-2 man pages says that a MAP_FILE flag is required. */
40 char *mapread(int, int);
41 int unmap(char *, int);
43 char *mapread(int fd, int nbytes)
45 char *p = (char *)mmap((void *)0, (size_t)nbytes, PROT_READ,
46 MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
49 /* mmap() shouldn't return 0 since MAP_FIXED wasn't specified. */
55 int unmap(char *p, int len)
57 return munmap((void *)p, len);
64 #else /* not HAVE_MMAP */
72 char *mapread(int fd, int nbytes)
78 int unmap(char *p, int len)
88 #endif /* not HAVE_MMAP */