aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppfiles.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cppfiles.c')
-rw-r--r--gcc/cppfiles.c28
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)