diff options
author | Christopher Faylor <cgf@redhat.com> | 2002-01-14 19:45:11 +0000 |
---|---|---|
committer | Christopher Faylor <cgf@gcc.gnu.org> | 2002-01-14 19:45:11 +0000 |
commit | 969815c71e073e2d32b1ae48dea4bed89c51de65 (patch) | |
tree | b91455dba9605013f85cce00dd4210d4073e5002 /gcc/cppfiles.c | |
parent | 494c950b2f873c82695aab855a90f1a6cd97e3df (diff) | |
download | gcc-969815c71e073e2d32b1ae48dea4bed89c51de65.zip gcc-969815c71e073e2d32b1ae48dea4bed89c51de65.tar.gz gcc-969815c71e073e2d32b1ae48dea4bed89c51de65.tar.bz2 |
cppfiles.c (TEST_THRESHOLD): New macro.
* cppfiles.c (TEST_THRESHOLD): New macro.
(SHOULD_MMAP): Ditto.
(read_include_file): Use SHOULD_MMAP macro to decide when mmap should be used.
From-SVN: r48840
Diffstat (limited to 'gcc/cppfiles.c')
-rw-r--r-- | gcc/cppfiles.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index b60e4eb..4fffce1 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -33,6 +33,26 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ # ifndef MMAP_THRESHOLD # define MMAP_THRESHOLD 3 /* Minimum page count to mmap the file. */ # endif +# if MMAP_THRESHOLD +# define TEST_THRESHOLD(size, pagesize) \ + (size / pagesize >= MMAP_THRESHOLD && (size % pagesize) != 0) + /* Use mmap if the file is big enough to be worth it (controlled + by MMAP_THRESHOLD) and if we can safely count on there being + at least one readable NUL byte after the end of the file's + contents. This is true for all tested operating systems when + the file size is not an exact multiple of the page size. */ +# ifndef __CYGWIN__ +# define SHOULD_MMAP(size, pagesize) TEST_THRESHOLD (size, pagesize) +# else +# define WIN32_LEAN_AND_MEAN +# include <windows.h> + /* Cygwin can't correctly emulate mmap under Windows 9x style systems so + disallow use of mmap on those systems. Windows 9x does not zero fill + memory at EOF and beyond, as required. */ +# define SHOULD_MMAP(size, pagesize) ((GetVersion() & 0x80000000) \ + ? 0 : TEST_THRESHOLD (size, pagesize)) +# endif +# endif #else /* No MMAP_FILE */ # undef MMAP_THRESHOLD @@ -382,13 +402,7 @@ read_include_file (pfile, inc) if (pagesize == -1) pagesize = getpagesize (); - /* Use mmap if the file is big enough to be worth it (controlled - by MMAP_THRESHOLD) and if we can safely count on there being - at least one readable NUL byte after the end of the file's - contents. This is true for all tested operating systems when - the file size is not an exact multiple of the page size. */ - if (size / pagesize >= MMAP_THRESHOLD - && (size % pagesize) != 0) + if (SHOULD_MMAP (size, pagesize)) { buf = (U_CHAR *) mmap (0, size, PROT_READ, MAP_PRIVATE, inc->fd, 0); if (buf == (U_CHAR *)-1) |