From: Andrew Tridgell Date: Wed, 27 Mar 2002 07:12:30 +0000 (+0100) Subject: explain the mmap code a little X-Git-Tag: v1.0~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7f1767724fec1a1b1405965df7db56e6632bcf99;p=thirdparty%2Fccache.git explain the mmap code a little --- diff --git a/ccache.c b/ccache.c index 17c620260..05f54694d 100644 --- a/ccache.c +++ b/ccache.c @@ -118,6 +118,9 @@ static void stabs_hash(const char *fname) failed(); } + /* we use mmap() to make it easy to handle arbitraryily long + lines in preprocessor output. I have seen lines of over + 100k in length, so this is well worth it */ map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (map == (void *)-1) { cc_log("Failed to mmap %s\n", fname); @@ -131,6 +134,8 @@ static void stabs_hash(const char *fname) while (l_end < st.st_size && map[l_end] != '\n') { l_end++; } + /* skip the hash on any lines that look like compiler line + numbers */ if ((l_end - l_start) > 2 && map[l_start] == '#' && map[l_start+1] == ' ' && isdigit(map[l_start+2])) { diff --git a/ccache.h b/ccache.h index cf2b1bb09..3b51d77df 100644 --- a/ccache.h +++ b/ccache.h @@ -19,8 +19,6 @@ #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 -#define MAX_LINE_SIZE 102400 - typedef unsigned uint32; #include "mdfour.h"