Revised^3 precompiled header support for cygwin
Billinghurst, David (CALCRTS)
david.billinghurst@comalco.riotinto.com.au
Mon Mar 7 04:57:00 GMT 2005
This consolidates previous patches for precompiled header support for cygwin
http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01211.html
http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01765.html
http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01838.html
I am testing it with 4.0 and 4.0 in daily posts to gcc-testresults.
Chris Faylor is considering alternatives and doesn't want this checked in
without his approval.
I have removed the patch to ggc-common.c, as it is not absolutely required,
so that the patch is now host specific.
Bootstrapped and tested on 4.0 and mainline.
2005-03-07 Earl Chew <earl_chew@agilent.com>
David Billinghurst <David.Billinghurst@riotinto.com>
* config/i386/host-cygwin.c: New file
* config/i386/x-cygwin: Use host-cygwin.c on cygwin host
* config.host: Use above files for cygwin host.
Index: config.host
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.host,v
retrieving revision 2.12
diff -u -p -r2.12 config.host
--- config.host 30 Nov 2004 03:11:28 -0000 2.12
+++ config.host 28 Feb 2005 01:16:11 -0000
@@ -146,6 +146,8 @@ case ${host} in
;;
i[34567]86-*-pe | i[34567]86-*-cygwin*)
host_xm_file=i386/xm-cygwin.h
+ out_host_hook_obj=host-cygwin.o
+ host_xmake_file=i386/x-cygwin
host_exeext=.exe
;;
i[34567]86-*-mingw32*)
--- /dev/null Mon Feb 28 12:17:04 2005
+++ config/i386/x-cygwin Sat Feb 26 12:00:31 2005
@@ -0,0 +1,4 @@
+host-cygwin.o : $(srcdir)/config/i386/host-cygwin.c $(CONFIG_H) $(SYSTEM_H) \
+ coretypes.h hosthooks.h hosthooks-def.h toplev.h diagnostic.h
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+ $(srcdir)/config/i386/host-cygwin.c
--- /dev/null Mon Mar 7 15:20:38 2005
+++ host-cygwin.c Mon Mar 7 15:38:19 2005
@@ -0,0 +1,85 @@
+/* Cygwin host-specific hook definitions.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include <sys/mman.h>
+#include "hosthooks.h"
+#include "hosthooks-def.h"
+#include "toplev.h"
+#include "diagnostic.h"
+
+
+static void * cygwin_gt_pch_get_address (size_t, int fd);
+static size_t cygwin_gt_pch_alloc_granularity (void);
+
+#undef HOST_HOOKS_GT_PCH_GET_ADDRESS
+#define HOST_HOOKS_GT_PCH_GET_ADDRESS cygwin_gt_pch_get_address
+#undef HOST_HOOKS_GT_PCH_ALLOC_GRANULARITY
+#define HOST_HOOKS_GT_PCH_ALLOC_GRANULARITY cygwin_gt_pch_alloc_granularity
+
+/* Granularity for reserving address space. */
+static const size_t va_granularity = 0x10000;
+
+/* Return the alignment required for allocating virtual memory. */
+static size_t
+cygwin_gt_pch_alloc_granularity (void)
+{
+ return va_granularity;
+}
+
+/* Identify an address that's likely to be free in a subsequent invocation
+ of the compiler. The area should be able to hold SIZE bytes. FD is an
+ open file descriptor if the host would like to probe with mmap. */
+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) == (off_t) -1 )
+ fatal_error ("can't seek past end of PCH file: %m");
+ if ( 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) == (off_t) -1 )
+ fatal_error ("can't set position in PCH file: %m");
+
+ return base;
+}
+
+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
NOTICE
This e-mail and any attachments are private and confidential and may contain privileged information. If you are not an authorised recipient, the copying or distribution of this e-mail and any attachments is prohibited and you must not read, print or act in reliance on this e-mail or attachments.
This notice should not be removed.
More information about the Gcc-patches
mailing list