diff options
author | Neil Booth <neil@daikokuya.co.uk> | 2003-04-19 00:22:51 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2003-04-19 00:22:51 +0000 |
commit | 26aea0737b2d0c4ee328d547555ae25ab5de9a0a (patch) | |
tree | 6e2502497aefe03b070107d7b41bbe6be454b727 /gcc/cppfiles.c | |
parent | 606c99912372a1fd5354765992eaef014ab78ce2 (diff) | |
download | gcc-26aea0737b2d0c4ee328d547555ae25ab5de9a0a.zip gcc-26aea0737b2d0c4ee328d547555ae25ab5de9a0a.tar.gz gcc-26aea0737b2d0c4ee328d547555ae25ab5de9a0a.tar.bz2 |
cppfiles.c (ENABLE_VALGRIND_CHECKING, [...]): Remove.
* cppfiles.c (ENABLE_VALGRIND_CHECKING, VALGRIND_DISCARD,
MMAP_THRESHOLD, TEST_THRESHOLD, SHOULD_MMAP): Remove.
(struct include_file): Remove fefcnt, mapped members.
(open_file, stack_include_file, _cpp_pop_file_buffer): Disable caching.
(read_include_file): Don't use mmap, terminate buffers in '\r'.
(purge_cache): Don't use munmap.
* cpphash.h (CPP_BUF_COLUMN): Update.
(lexer_state): Remove lexing_comment.
(struct _cpp_line_note): New.
(struct cpp_buffer): New members cur_note, notes_used, notes_cap,
next_line and need_line. Remove col_adjust and saved_flags.
(_cpp_process_line_notes, _cpp_clean_line, _cpp_get_fresh_line,
_cpp_skip_block_comment, scan_out_logical_line): New.
(_cpp_init_mbchar): Remove.
* cppinit.c (init_library): Remove call to _cpp_init_mbchar.
(cpp_read_main_file): Set line to 1 earlier.
(post_options): -traditional-cpp doesn't want trigraphs.
* cpplex.c (MULTIBYTE_CHARS): Remove code predicated on this.
(add_line_note, _cpp_clean_line, _cpp_process_line_notes,
_cpp_get_fresh_line): New.
(handle_newline, skip_escaped_newlines, trigraph_p,
continue_after_nul, _cpp_init_mbchar): Remove.
(get_effective_char): Update.
(_cpp_skip_block_comment): Rename from skip_block_comment, simplify.
(skip_line_comment): Simplify.
(skip_whitespace, parse_identifier, parse_slow, parse_number,
parse_string): Update.
(cpp_lex_direct): Use clean lines and process line notes. Update.
(cpp_interpret_charconst): No MULTIBYTE_CHARS.
* cpplib.c (prepare_directive_trad): Call scan_out_logical_line
directly.
(_cpp_handle_directive): Don't set saved_flags.
(run_directive, destringize_and_run, cpp_define, cpp_define_builtin,
cpp_undef, handle_assertion, cpp_push_buffer): Update.
(_cpp_pop_buffer): Free notes.
* cppmacro.c (builtin_macro, paste_tokens): \n terminate buffer.
* cpppch.c (cpp_read_state): \n terminate buffer.
* cpptrad.c (skip_escaped_newlines, handle_newline): Remove.
(copy_comment): Use _cpp_skip_block_comment.
(skip_whitespace, lex_identifier, _cpp_read_logical_line_trad):
Simplify.
(_cpp_overlay_buffer, _cpp_remove_overlay, push_replacement_text,
save_replacement_text): Update.
(scan_out_logical_line): Update to use clean lines and process
line notes.
* fix-header.c (read_scan_file): Update.
testsuite:
* gcc.dg/cpp/_Pragma4.c: Remove stray space.
* gcc.dg/cpp/trad/escaped-eof.c: Correct line number.
From-SVN: r65808
Diffstat (limited to 'gcc/cppfiles.c')
-rw-r--r-- | gcc/cppfiles.c | 98 |
1 files changed, 9 insertions, 89 deletions
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 1ff34ff..4b8643d 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -30,47 +30,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "intl.h" #include "mkdeps.h" #include "splay-tree.h" -#ifdef ENABLE_VALGRIND_CHECKING -# ifdef HAVE_MEMCHECK_H -# include <memcheck.h> -# else -# include <valgrind.h> -# endif -#else -/* Avoid #ifdef:s when we can help it. */ -#define VALGRIND_DISCARD(x) -#endif - -#ifdef HAVE_MMAP_FILE -# include <sys/mman.h> -# 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 -# define MMAP_THRESHOLD 0 -#endif #ifndef O_BINARY # define O_BINARY 0 @@ -102,8 +61,6 @@ struct include_file { int fd; /* fd open on file (short term storage only) */ int err_no; /* errno obtained if opening a file failed */ unsigned short include_count; /* number of times file has been read */ - unsigned short refcnt; /* number of stacked buffers using this file */ - unsigned char mapped; /* file buffer is mmapped */ unsigned char pch; /* 0: file not known to be a PCH. 1: file is a PCH (on return from find_include_file). @@ -278,7 +235,7 @@ open_file (pfile, filename) return file; /* Don't reopen one which is already loaded. */ - if (file->buffer != NULL) + if (0 && file->buffer != NULL) return file; /* We used to open files in nonblocking mode, but that caused more @@ -446,7 +403,7 @@ stack_include_file (pfile, inc) } /* Not in cache? */ - if (! inc->buffer) + if (1 || ! inc->buffer) { if (read_include_file (pfile, inc)) { @@ -471,7 +428,6 @@ stack_include_file (pfile, inc) fp = cpp_push_buffer (pfile, inc->buffer, inc->st.st_size, /* from_stage3 */ CPP_OPTION (pfile, preprocessed), 0); fp->inc = inc; - fp->inc->refcnt++; /* Initialize controlling macro state. */ pfile->mi_valid = true; @@ -507,9 +463,6 @@ read_include_file (pfile, inc) { ssize_t size, offset, count; uchar *buf; -#if MMAP_THRESHOLD - static int pagesize = -1; -#endif if (S_ISREG (inc->st.st_mode)) { @@ -528,25 +481,6 @@ read_include_file (pfile, inc) } size = inc->st.st_size; - inc->mapped = 0; -#if MMAP_THRESHOLD - if (pagesize == -1) - pagesize = getpagesize (); - - if (SHOULD_MMAP (size, pagesize)) - { - buf = (uchar *) mmap (0, size, PROT_READ, MAP_PRIVATE, inc->fd, 0); - if (buf == (uchar *) -1) - goto perror_fail; - - /* We must tell Valgrind that the byte at buf[size] is actually - readable. Discard the handle to avoid handle leak. */ - VALGRIND_DISCARD (VALGRIND_MAKE_READABLE (buf + size, 1)); - - inc->mapped = 1; - } - else -#endif { buf = (uchar *) xmalloc (size + 1); offset = 0; @@ -567,8 +501,8 @@ read_include_file (pfile, inc) } offset += count; } - /* The lexer requires that the buffer be NUL-terminated. */ - buf[size] = '\0'; + /* The lexer requires that the buffer be \n-terminated. */ + buf[size] = '\n'; } } else if (S_ISBLK (inc->st.st_mode)) @@ -600,8 +534,8 @@ read_include_file (pfile, inc) if (offset + 1 < size) buf = xrealloc (buf, offset + 1); - /* The lexer requires that the buffer be NUL-terminated. */ - buf[offset] = '\0'; + /* The lexer requires that the buffer be \n-terminated. */ + buf[offset] = '\n'; inc->st.st_size = offset; } @@ -614,26 +548,14 @@ read_include_file (pfile, inc) return 1; } -/* Drop INC's buffer from memory, if we are unlikely to need it again. */ +/* Drop INC's buffer from memory. */ static void purge_cache (inc) struct include_file *inc; { if (inc->buffer) { -#if MMAP_THRESHOLD - if (inc->mapped) - { - /* Undo the previous annotation for the - known-zero-byte-after-mmap. Discard the handle to avoid - handle leak. */ - VALGRIND_DISCARD (VALGRIND_MAKE_NOACCESS (inc->buffer - + inc->st.st_size, 1)); - munmap ((PTR) inc->buffer, inc->st.st_size); - } - else -#endif - free ((PTR) inc->buffer); + free ((PTR) inc->buffer); inc->buffer = NULL; } } @@ -929,9 +851,7 @@ _cpp_pop_file_buffer (pfile, inc) /* Invalidate control macros in the #including file. */ pfile->mi_valid = false; - inc->refcnt--; - if (inc->refcnt == 0 && DO_NOT_REREAD (inc)) - purge_cache (inc); + purge_cache (inc); } /* Returns the first place in the include chain to start searching for |