lyxsum/mmap compatibility patch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3251 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-12-19 16:11:10 +00:00
parent bdfd6bb075
commit b8ec942f92
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,7 @@
2001-12-12 Ben Stanley <bds02@uow.edu.au>
* lyxsum.C: portability fix for mmap patch
2001-12-05 Lars Gullik Bjønnes <larsbj@birdstep.com>
* filetools.C:

View File

@ -23,6 +23,10 @@
#warning lyx::sum() using mmap (lightning fast)
#endif
// Make sure we get modern version of mmap and friends with void*,
// not `compatibility' version with caddr_t.
#define _POSIX_C_SOURCE 199506L
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -40,7 +44,8 @@ unsigned long lyx::sum(string const & file)
void * mm = mmap(0, info.st_size, PROT_READ,
MAP_PRIVATE, fd, 0);
if (mm == MAP_FAILED) {
// Some platforms have the wrong type for MAP_FAILED (compaq cxx).
if (mm == reinterpret_cast<void*>(MAP_FAILED)) {
close(fd);
return 0;
}