From 969815c71e073e2d32b1ae48dea4bed89c51de65 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 14 Jan 2002 19:45:11 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 7 +++++++ gcc/cppfiles.c | 28 +++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 46495eb..5e6c588 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2002-01-13 Christopher Faylor + + * cppfiles.c (TEST_THRESHOLD): New macro. + (SHOULD_MMAP): Ditto. + (read_include_file): Use SHOULD_MMAP macro to decide when mmap should + be used. + Mon Jan 14 20:23:34 CET 2002 Jan Hubicka * unroll.c (final_reg_note_copy): Properly handle 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 + /* 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) -- 2.7.4