Commit 969815c7 by Christopher Faylor Committed by Christopher Faylor

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
parent 494c950b
2002-01-13 Christopher Faylor <cgf@redhat.com>
* 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 <jh@suse.cz>
* unroll.c (final_reg_note_copy): Properly handle
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment