This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Revised^2 precompiled header support for cygwin
- From: Earl Chew <earl_chew at agilent dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "Billinghurst, David (CALCRTS)" <david dot billinghurst at comalco dot riotinto dot com dot au>
- Date: Mon, 28 Feb 2005 10:50:49 -0800
- Subject: Re: Revised^2 precompiled header support for cygwin
- References: <026DCC31AB859648A6F16C0E5CD2580D056B5C@calttsv025.cal.riotinto.org>
Billinghurst, David (CALCRTS) wrote:
This patch is based on Earl Chew's 3.4 patch for precompiled header support for cygwin
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01211.html
Earl: Let we know if you no longer want your name associated with this?
David, thanks for following up and integrating my patch into something
more recent.
Mainline has the additional hooks required, so this is much less intrusive.
Yes, the new scheme has improvements over the older one.
One thing I was unsure about. In host-cygwin.c(cygwin_gt_pch_get_address)
I use fdopen to associate a stream with a file descriptor. Should I
close the stream or not? I don't see any "bad things" if I leave the
stream open.
This is not nice in the sense that the FILE* is leaked. In hindsight,
I think it's better if the code simply use the raw fd as is, rather
than trying to paste a FILE* over the top of it. At this point, this
code is Cygwin specific, so there is no need to attempt to try to
use stdio for portability.
I think the following would be better:
static void *
cygwin_gt_pch_get_address (size_t sz, int fd)
{
void *base;
off_t p = lseek(fd, 0, SEEK_CUR);
if (p == (off_t) -1)
fatal_error ("can't get position in PCH file: %m");
/* Cygwin requires that the underlying file be at least
as large as the requested mapping. */
if ((size_t) p < sz)
{
if ( lseek (fd, sz-1, SEEK_SET) != 0
|| write (fd, '\0', 1) == 1 )
fatal_error ("can't extend PCH file: %m");
}
base = mmap (NULL, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
if (base == MAP_FAILED)
base = NULL;
else
munmap (base, sz);
if (lseek (fd, p, SEEK_SET) != 0)
fatal_error ("can't set position in PCH file: %m");
return base;
}
Earl
--
> ---------------------------------------------------------------------+
> Earl Chew http://www.agilent.com |
> Agilent Technologies mailto:earl_chew@agilent.com |
> Data Networks Division Tel: +1 604 454 3411 |
> 2500-4710 Kingsway Fax: +1 604 454 3401 |
> Burnaby BC V5H 4M2 Canada |
> ---------------------------------------------------------------------+