diff options
author | cgf <cgf@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-01-14 19:45:11 +0000 |
---|---|---|
committer | cgf <cgf@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-01-14 19:45:11 +0000 |
commit | c21f4dc1c36719759388dcf96483bc0c43e89a83 (patch) | |
tree | b91455dba9605013f85cce00dd4210d4073e5002 /gcc/cppfiles.c | |
parent | 45c2115a40f949fd49bd27830d2e7be1bdf3e5c3 (diff) | |
download | gcc-c21f4dc1c36719759388dcf96483bc0c43e89a83.tar.gz |
* cppfiles.c (TEST_THRESHOLD): New macro.
(SHOULD_MMAP): Ditto.
(read_include_file): Use SHOULD_MMAP macro to decide when mmap should be used.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48840 138bc75d-0d04-0410-961f-82ee72b054a4
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 b60e4eba0f0..4fffce1ce08 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) |