host-mingw32.c (va_granularity): Make none-const.
* config/i386/host-mingw32.c (va_granularity): Make none-const. (mingw32_gt_pch_alloc_granularity): Return OS' allocation granularity. (mingw32_gt_pch_use_address): Retry mapping of used address as multiple instances might interfer. From-SVN: r193987
This commit is contained in:
parent
d71576d634
commit
e7b0b62dc0
|
@ -1,5 +1,11 @@
|
|||
2012-11-30 Kai Tietz <ktietz@redhat.com>
|
||||
|
||||
* config/i386/host-mingw32.c (va_granularity): Make none-const.
|
||||
(mingw32_gt_pch_alloc_granularity): Return OS' allocation
|
||||
granularity.
|
||||
(mingw32_gt_pch_use_address): Retry mapping of used address
|
||||
as multiple instances might interfer.
|
||||
|
||||
* config/i386/mingw32.h (SHARED_LIBGCC_SPEC): Synchronize with
|
||||
cygwin-host.
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#define WIN32_LEAN_AND_MEAN /* Not so important if we have windows.h.gch. */
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void * mingw32_gt_pch_get_address (size_t, int);
|
||||
static int mingw32_gt_pch_use_address (void *, size_t, int, size_t);
|
||||
|
@ -45,7 +46,7 @@ static inline void w32_error(const char*, const char*, int, const char*);
|
|||
static const size_t pch_VA_max_size = 128 * 1024 * 1024;
|
||||
|
||||
/* Granularity for reserving address space. */
|
||||
static const size_t va_granularity = 0x10000;
|
||||
static size_t va_granularity = 0x10000;
|
||||
|
||||
/* Print out the GetLastError() translation. */
|
||||
static inline void
|
||||
|
@ -66,8 +67,14 @@ w32_error (const char* function, const char* file, int line,
|
|||
}
|
||||
|
||||
/* Granularity for reserving address space. */
|
||||
static size_t mingw32_gt_pch_alloc_granularity (void)
|
||||
static size_t
|
||||
mingw32_gt_pch_alloc_granularity (void)
|
||||
{
|
||||
SYSTEM_INFO si;
|
||||
|
||||
GetSystemInfo (&si);
|
||||
va_granularity = (size_t) si.dwAllocationGranularity;
|
||||
|
||||
return va_granularity;
|
||||
}
|
||||
|
||||
|
@ -114,7 +121,7 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
|
|||
{
|
||||
void * mmap_addr;
|
||||
HANDLE mmap_handle;
|
||||
|
||||
|
||||
/* Apparently, MS Vista puts unnamed file mapping objects into Global
|
||||
namespace when running an application in a Terminal Server
|
||||
session. This causes failure since, by default, applications
|
||||
|
@ -132,6 +139,8 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
|
|||
and earlier, backslashes are invalid in object name. So, we need
|
||||
to check if we are on Windows2000 or higher. */
|
||||
OSVERSIONINFO version_info;
|
||||
int r;
|
||||
|
||||
version_info.dwOSVersionInfoSize = sizeof (version_info);
|
||||
|
||||
if (size == 0)
|
||||
|
@ -154,7 +163,6 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
|
|||
OBJECT_NAME_FMT "%lx", GetCurrentProcessId());
|
||||
object_name = local_object_name;
|
||||
}
|
||||
|
||||
mmap_handle = CreateFileMappingA ((HANDLE) _get_osfhandle (fd), NULL,
|
||||
PAGE_WRITECOPY | SEC_COMMIT, 0, 0,
|
||||
object_name);
|
||||
|
@ -164,8 +172,19 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd,
|
|||
w32_error (__FUNCTION__, __FILE__, __LINE__, "CreateFileMapping");
|
||||
return -1;
|
||||
}
|
||||
mmap_addr = MapViewOfFileEx (mmap_handle, FILE_MAP_COPY, 0, offset,
|
||||
size, addr);
|
||||
|
||||
/* Retry five times, as here might occure a race with multiple gcc's
|
||||
instances at same time. */
|
||||
for (r = 0; r < 5; r++)
|
||||
{
|
||||
mmap_addr = MapViewOfFileEx (mmap_handle, FILE_MAP_COPY, 0, offset,
|
||||
size, addr);
|
||||
if (mmap_addr == addr)
|
||||
break;
|
||||
if (r != 4)
|
||||
Sleep (500);
|
||||
}
|
||||
|
||||
if (mmap_addr != addr)
|
||||
{
|
||||
w32_error (__FUNCTION__, __FILE__, __LINE__, "MapViewOfFileEx");
|
||||
|
|
Loading…
Reference in New Issue