diff options
author | Danny Smith <dannysmith@users.sourceforge.net> | 2009-04-08 08:02:48 +0000 |
---|---|---|
committer | Danny Smith <dannysmith@gcc.gnu.org> | 2009-04-08 08:02:48 +0000 |
commit | 8e481a2ca6dcab968cc8c18f0fdc6745e75b8afc (patch) | |
tree | 2f889b301b803e3f51a017333494a70f0c1c1fc6 /gcc | |
parent | e04c614e09867345ee8ac03390cc75c5f2f1de1e (diff) | |
download | gcc-8e481a2ca6dcab968cc8c18f0fdc6745e75b8afc.zip gcc-8e481a2ca6dcab968cc8c18f0fdc6745e75b8afc.tar.gz gcc-8e481a2ca6dcab968cc8c18f0fdc6745e75b8afc.tar.bz2 |
re PR bootstrap/39660 (Mingw Bootstrap stops with "..host-mingw32.c:140: error: ISO C90 forbids mixed..")
PR bootstrap/39660
* config/i386/host-mingw32.c (mingw32_gt_pch_use_address): Don't
mix declarations and code.
From-SVN: r145711
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/i386/host-mingw32.c | 39 |
2 files changed, 28 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 46a98f2..c2091e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-04-08 Danny Smith <dannysmith@users.sourceforge.net> + + PR bootstrap/39660 + * config/i386/host-mingw32.c (mingw32_gt_pch_use_address): Don't + mix declarations and code. + 2009-04-08 Ben Elliston <bje@au.ibm.com> * gcc.c: Replace `CC' with `GCC' throughout. diff --git a/gcc/config/i386/host-mingw32.c b/gcc/config/i386/host-mingw32.c index 1d2e59a..f91407f 100644 --- a/gcc/config/i386/host-mingw32.c +++ b/gcc/config/i386/host-mingw32.c @@ -1,5 +1,5 @@ /* mingw32 host-specific hook definitions. - Copyright (C) 2004, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc. This file is part of GCC. @@ -122,23 +122,19 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd, don't get SeCreateGlobalPrivilege. We don't need global memory sharing so explicitly put object into Local namespace. - There is also another issue, which appears if multiple concurrent - GCC processes are using PCH functionality. MapViewOfFileEx returns - "Access Denied" error. So we need to make the session-wide mapping - name unique. Let's use current process ID for that. */ -#define OBJECT_NAME_FMT "Local\\MinGWGCCPCH-" + If multiple concurrent GCC processes are using PCH functionality, + MapViewOfFileEx returns "Access Denied" error. So we ensure the + session-wide mapping name is unique by appending process ID. */ - /* Allocate enough space for name prefix and max possible DWORD - hexadecimal representation. */ - char object_name[sizeof (OBJECT_NAME_FMT) + sizeof (DWORD) * 2]; - snprintf (object_name, sizeof (object_name), OBJECT_NAME_FMT "%lx", - GetCurrentProcessId()); +#define OBJECT_NAME_FMT "Local\\MinGWGCCPCH-" + char* object_name = NULL; /* However, the documentation for CreateFileMapping says that on NT4 and earlier, backslashes are invalid in object name. So, we need to check if we are on Windows2000 or higher. */ OSVERSIONINFO version_info; - + version_info.dwOSVersionInfoSize = sizeof (version_info); + if (size == 0) return 0; @@ -147,14 +143,23 @@ mingw32_gt_pch_use_address (void *addr, size_t size, int fd, if ((offset & (va_granularity - 1)) != 0 || size > pch_VA_max_size) return -1; - /* Determine the version of Windows we are running on. */ - version_info.dwOSVersionInfoSize = sizeof (version_info); - GetVersionEx (&version_info); + /* Determine the version of Windows we are running on and use a + uniquely-named local object if running > 4. */ + GetVersionEx (&version_info); + if (version_info.dwMajorVersion > 4) + { + char local_object_name [sizeof (OBJECT_NAME_FMT) + + sizeof (DWORD) * 2]; + snprintf (local_object_name, sizeof (local_object_name), + OBJECT_NAME_FMT "%lx", GetCurrentProcessId()); + object_name = local_object_name; + } + mmap_handle = CreateFileMappingA ((HANDLE) _get_osfhandle (fd), NULL, PAGE_WRITECOPY | SEC_COMMIT, 0, 0, - version_info.dwMajorVersion > 4 - ? object_name : NULL); + object_name); + if (mmap_handle == NULL) { w32_error (__FUNCTION__, __FILE__, __LINE__, "CreateFileMapping"); |