diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-05-26 20:36:21 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-05-26 20:36:21 +0000 |
commit | bca9ab3d1a3ad076f577925a00bd6e071bb97408 (patch) | |
tree | b461d46419a1b521086f770bf8f7922e8598b029 /read.c | |
parent | e23d8aec20758e4e3134d8a5a4fd7484929aef72 (diff) | |
download | mandoc-bca9ab3d1a3ad076f577925a00bd6e071bb97408.tar.gz |
At least in theory, this patch lets us compile on Windows (which does
not have mmap(), from what I can tell).
Diffstat (limited to 'read.c')
-rw-r--r-- | read.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -19,8 +19,10 @@ #include "config.h" #endif -#include <sys/stat.h> -#include <sys/mman.h> +#ifdef HAVE_MMAP +# include <sys/stat.h> +# include <sys/mman.h> +#endif #include <assert.h> #include <ctype.h> @@ -529,19 +531,22 @@ pdesc(struct mparse *curp, const char *file, int fd) mparse_buf_r(curp, blk, 1); +#ifdef HAVE_MMAP if (with_mmap) munmap(blk.buf, blk.sz); else +#endif free(blk.buf); } static int read_whole_file(const char *file, int fd, struct buf *fb, int *with_mmap) { - struct stat st; size_t off; ssize_t ssz; +#ifdef HAVE_MMAP + struct stat st; if (-1 == fstat(fd, &st)) { perror(file); return(0); @@ -566,6 +571,7 @@ read_whole_file(const char *file, int fd, struct buf *fb, int *with_mmap) if (fb->buf != MAP_FAILED) return(1); } +#endif /* * If this isn't a regular file (like, say, stdin), then we must |