Mercurial > hg > CbC > CbC_gcc
comparison gcc/config/i386/host-mingw32.c @ 57:326d9e06c2e3
modify c-parser.c
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 15 Feb 2010 00:54:17 +0900 |
parents | 77e2b8dfacca |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
54:f62c169bbc24 | 57:326d9e06c2e3 |
---|---|
1 /* mingw32 host-specific hook definitions. | 1 /* mingw32 host-specific hook definitions. |
2 Copyright (C) 2004, 2007 Free Software Foundation, Inc. | 2 Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GCC. | 4 This file is part of GCC. |
5 | 5 |
6 GCC is free software; you can redistribute it and/or modify it | 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 | 7 under the terms of the GNU General Public License as published |
120 namespace when running an application in a Terminal Server | 120 namespace when running an application in a Terminal Server |
121 session. This causes failure since, by default, applications | 121 session. This causes failure since, by default, applications |
122 don't get SeCreateGlobalPrivilege. We don't need global | 122 don't get SeCreateGlobalPrivilege. We don't need global |
123 memory sharing so explicitly put object into Local namespace. | 123 memory sharing so explicitly put object into Local namespace. |
124 | 124 |
125 There is also another issue, which appears if multiple concurrent | 125 If multiple concurrent GCC processes are using PCH functionality, |
126 GCC processes are using PCH functionality. MapViewOfFileEx returns | 126 MapViewOfFileEx returns "Access Denied" error. So we ensure the |
127 "Access Denied" error. So we need to make the session-wide mapping | 127 session-wide mapping name is unique by appending process ID. */ |
128 name unique. Let's use current process ID for that. */ | 128 |
129 #define OBJECT_NAME_FMT "Local\\MinGWGCCPCH-" | 129 #define OBJECT_NAME_FMT "Local\\MinGWGCCPCH-" |
130 | 130 |
131 /* Allocate enough space for name prefix and max possible DWORD | 131 char* object_name = NULL; |
132 hexadecimal representation. */ | |
133 char object_name[sizeof (OBJECT_NAME_FMT) + sizeof (DWORD) * 2]; | |
134 snprintf (object_name, sizeof (object_name), OBJECT_NAME_FMT "%lx", | |
135 GetCurrentProcessId()); | |
136 | |
137 /* However, the documentation for CreateFileMapping says that on NT4 | 132 /* However, the documentation for CreateFileMapping says that on NT4 |
138 and earlier, backslashes are invalid in object name. So, we need | 133 and earlier, backslashes are invalid in object name. So, we need |
139 to check if we are on Windows2000 or higher. */ | 134 to check if we are on Windows2000 or higher. */ |
140 OSVERSIONINFO version_info; | 135 OSVERSIONINFO version_info; |
141 | 136 version_info.dwOSVersionInfoSize = sizeof (version_info); |
137 | |
142 if (size == 0) | 138 if (size == 0) |
143 return 0; | 139 return 0; |
144 | 140 |
145 /* Offset must be also be a multiple of allocation granularity for | 141 /* Offset must be also be a multiple of allocation granularity for |
146 this to work. We can't change the offset. */ | 142 this to work. We can't change the offset. */ |
147 if ((offset & (va_granularity - 1)) != 0 || size > pch_VA_max_size) | 143 if ((offset & (va_granularity - 1)) != 0 || size > pch_VA_max_size) |
148 return -1; | 144 return -1; |
149 | 145 |
150 /* Determine the version of Windows we are running on. */ | 146 |
151 version_info.dwOSVersionInfoSize = sizeof (version_info); | 147 /* Determine the version of Windows we are running on and use a |
148 uniquely-named local object if running > 4. */ | |
152 GetVersionEx (&version_info); | 149 GetVersionEx (&version_info); |
153 | 150 if (version_info.dwMajorVersion > 4) |
151 { | |
152 char local_object_name [sizeof (OBJECT_NAME_FMT) | |
153 + sizeof (DWORD) * 2]; | |
154 snprintf (local_object_name, sizeof (local_object_name), | |
155 OBJECT_NAME_FMT "%lx", GetCurrentProcessId()); | |
156 object_name = local_object_name; | |
157 } | |
158 | |
154 mmap_handle = CreateFileMappingA ((HANDLE) _get_osfhandle (fd), NULL, | 159 mmap_handle = CreateFileMappingA ((HANDLE) _get_osfhandle (fd), NULL, |
155 PAGE_WRITECOPY | SEC_COMMIT, 0, 0, | 160 PAGE_WRITECOPY | SEC_COMMIT, 0, 0, |
156 version_info.dwMajorVersion > 4 | 161 object_name); |
157 ? object_name : NULL); | 162 |
158 if (mmap_handle == NULL) | 163 if (mmap_handle == NULL) |
159 { | 164 { |
160 w32_error (__FUNCTION__, __FILE__, __LINE__, "CreateFileMapping"); | 165 w32_error (__FUNCTION__, __FILE__, __LINE__, "CreateFileMapping"); |
161 return -1; | 166 return -1; |
162 } | 167 } |