OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [config/] [i386/] [host-cygwin.c] - Blame information for rev 709

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 709 jeremybenn
/* Cygwin host-specific hook definitions.
2
 Copyright (C) 2004, 2007, 2010 Free Software Foundation, Inc.
3
 
4
 This file is part of GCC.
5
 
6
 GCC is free software; you can redistribute it and/or modify it
7
 under the terms of the GNU General Public License as published
8
 by the Free Software Foundation; either version 3, or (at your
9
 option) any later version.
10
 
11
 GCC is distributed in the hope that it will be useful, but WITHOUT
12
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14
 License for more details.
15
 
16
 You should have received a copy of the GNU General Public License
17
 along with GCC; see the file COPYING3.  If not see
18
 <http://www.gnu.org/licenses/>. */
19
 
20
#include "config.h"
21
#include "system.h"
22
#include "coretypes.h"
23
#include "hosthooks.h"
24
#include "hosthooks-def.h"
25
#include "diagnostic.h"
26
 
27
static void * cygwin_gt_pch_get_address (size_t, int fd);
28
static size_t cygwin_gt_pch_alloc_granularity (void);
29
 
30
#undef HOST_HOOKS_GT_PCH_GET_ADDRESS
31
#define HOST_HOOKS_GT_PCH_GET_ADDRESS cygwin_gt_pch_get_address
32
#undef HOST_HOOKS_GT_PCH_ALLOC_GRANULARITY
33
#define HOST_HOOKS_GT_PCH_ALLOC_GRANULARITY cygwin_gt_pch_alloc_granularity
34
 
35
/* Granularity for reserving address space.  */
36
static const size_t va_granularity = 0x10000;
37
 
38
/*  Return the alignment required for allocating virtual memory. */
39
static size_t
40
cygwin_gt_pch_alloc_granularity (void)
41
{
42
  return va_granularity;
43
}
44
 
45
/* Identify an address that's likely to be free in a subsequent invocation
46
   of the compiler.  The area should be able to hold SIZE bytes.  FD is an
47
   open file descriptor if the host would like to probe with mmap.  */
48
static void *
49
cygwin_gt_pch_get_address (size_t sz, int fd)
50
{
51
  void *base;
52
  off_t p = lseek(fd, 0, SEEK_CUR);
53
 
54
  if (p == (off_t) -1)
55
    fatal_error ("can%'t get position in PCH file: %m");
56
 
57
   /* Cygwin requires that the underlying file be at least
58
      as large as the requested mapping.  */
59
  if ((size_t) p < sz)
60
  {
61
    if ( ftruncate (fd, sz) == -1 )
62
      fatal_error ("can%'t extend PCH file: %m");
63
  }
64
 
65
  base = mmap (NULL, sz, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
66
 
67
  if (base == MAP_FAILED)
68
    base = NULL;
69
  else
70
    munmap (base, sz);
71
 
72
  if (lseek (fd, p, SEEK_SET) == (off_t) -1 )
73
    fatal_error ("can%'t set position in PCH file: %m");
74
 
75
  return base;
76
}
77
 
78
const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.