Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: nss/patches/nspr-static.patch

Issue 3113004: Replace the workaround for bug 40663 by the real fix.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « nss/patches/nspr-attach-as-system-thread.patch ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Index: mozilla/nsprpub/pr/include/prtypes.h 1 Index: mozilla/nsprpub/pr/include/prtypes.h
2 =================================================================== 2 ===================================================================
3 RCS file: /cvsroot/mozilla/nsprpub/pr/include/prtypes.h,v 3 RCS file: /cvsroot/mozilla/nsprpub/pr/include/prtypes.h,v
4 retrieving revision 3.41 4 retrieving revision 3.43
5 diff -p -u -8 -r3.41 prtypes.h 5 diff -p -u -8 -r3.43 prtypes.h
6 --- mozilla/nsprpub/pr/include/prtypes.h» 6 May 2009 05:40:35 -0000» 3.41 6 --- mozilla/nsprpub/pr/include/prtypes.h» 11 Jun 2010 01:34:54 -0000» 3.43
7 +++ mozilla/nsprpub/pr/include/prtypes.h» 15 Jan 2010 01:23:40 -0000 7 +++ mozilla/nsprpub/pr/include/prtypes.h» 10 Aug 2010 01:06:02 -0000
8 @@ -75,17 +75,33 @@ 8 @@ -75,17 +75,33 @@
9 ** Example: 9 ** Example:
10 ** in dowhim.h 10 ** in dowhim.h
11 ** PR_EXTERN( void ) DoWhatIMean( void ); 11 ** PR_EXTERN( void ) DoWhatIMean( void );
12 ** in dowhim.c 12 ** in dowhim.c
13 ** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; } 13 ** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; }
14 ** 14 **
15 ** 15 **
16 ***********************************************************************/ 16 ***********************************************************************/
17 -#if defined(WIN32) 17 -#if defined(WIN32)
(...skipping 21 matching lines...) Expand all
39 #define PR_IMPORT_DATA(__type) __declspec(dllimport) __type 39 #define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
40 40
41 #define PR_EXTERN(__type) extern __declspec(dllexport) __type 41 #define PR_EXTERN(__type) extern __declspec(dllexport) __type
42 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type 42 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type
43 Index: mozilla/nsprpub/pr/src/md/windows/w95dllmain.c 43 Index: mozilla/nsprpub/pr/src/md/windows/w95dllmain.c
44 =================================================================== 44 ===================================================================
45 RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/windows/w95dllmain.c,v 45 RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/windows/w95dllmain.c,v
46 retrieving revision 3.8 46 retrieving revision 3.8
47 diff -p -u -8 -r3.8 w95dllmain.c 47 diff -p -u -8 -r3.8 w95dllmain.c
48 --- mozilla/nsprpub/pr/src/md/windows/w95dllmain.c 25 Apr 2004 15:01:00 -00 00 3.8 48 --- mozilla/nsprpub/pr/src/md/windows/w95dllmain.c 25 Apr 2004 15:01:00 -00 00 3.8
49 +++ mozilla/nsprpub/pr/src/md/windows/w95dllmain.c» 15 Jan 2010 01:23:40 -00 00 49 +++ mozilla/nsprpub/pr/src/md/windows/w95dllmain.c» 10 Aug 2010 01:06:02 -00 00
50 @@ -30,16 +30,18 @@ 50 @@ -30,16 +30,18 @@
51 * use your version of this file under the terms of the MPL, indicate your 51 * use your version of this file under the terms of the MPL, indicate your
52 * decision by deleting the provisions above and replace them with the notice 52 * decision by deleting the provisions above and replace them with the notice
53 * and other provisions required by the GPL or the LGPL. If you do not delete 53 * and other provisions required by the GPL or the LGPL. If you do not delete
54 * the provisions above, a recipient may use your version of this file under 54 * the provisions above, a recipient may use your version of this file under
55 * the terms of any one of the MPL, the GPL or the LGPL. 55 * the terms of any one of the MPL, the GPL or the LGPL.
56 * 56 *
57 * ***** END LICENSE BLOCK ***** */ 57 * ***** END LICENSE BLOCK ***** */
58 58
59 +#if 0 /* STATIC LIBRARIES. See the end of w95thred.c. */ 59 +#if 0 /* STATIC LIBRARIES. See the end of w95thred.c. */
(...skipping 13 matching lines...) Expand all
73 case DLL_PROCESS_DETACH: 73 case DLL_PROCESS_DETACH:
74 break; 74 break;
75 } 75 }
76 return TRUE; 76 return TRUE;
77 } 77 }
78 + 78 +
79 +#endif 79 +#endif
80 Index: mozilla/nsprpub/pr/src/md/windows/w95thred.c 80 Index: mozilla/nsprpub/pr/src/md/windows/w95thred.c
81 =================================================================== 81 ===================================================================
82 RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/windows/w95thred.c,v 82 RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/windows/w95thred.c,v
83 retrieving revision 3.18 83 retrieving revision 3.19
84 diff -p -u -8 -r3.18 w95thred.c 84 diff -p -u -8 -r3.19 w95thred.c
85 --- mozilla/nsprpub/pr/src/md/windows/w95thred.c» 4 Feb 2009 23:44:01 -000 0» 3.18 85 --- mozilla/nsprpub/pr/src/md/windows/w95thred.c» 11 Jun 2010 01:34:54 -00 00» 3.19
86 +++ mozilla/nsprpub/pr/src/md/windows/w95thred.c» 15 Jan 2010 01:23:40 -00 00 86 +++ mozilla/nsprpub/pr/src/md/windows/w95thred.c» 10 Aug 2010 01:06:02 -00 00
87 @@ -309,8 +309,115 @@ PRThread *thread; 87 @@ -309,8 +309,121 @@ PRThread *thread;
88 88
89 if (NULL == thread) { 89 if (NULL == thread) {
90 thread = _PRI_AttachThread( 90 thread = _PRI_AttachThread(
91 PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0); 91 PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0);
92 } 92 }
93 PR_ASSERT(thread != NULL); 93 PR_ASSERT(thread != NULL);
94 return thread; 94 return thread;
95 } 95 }
96 + 96 +
97 +// The following code is from Chromium src/base/thread_local_storage_win.cc, 97 +// The following code is from Chromium src/base/thread_local_storage_win.cc,
(...skipping 27 matching lines...) Expand all
125 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 125 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
126 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 126 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
127 + 127 +
128 +// Thread Termination Callbacks. 128 +// Thread Termination Callbacks.
129 +// Windows doesn't support a per-thread destructor with its 129 +// Windows doesn't support a per-thread destructor with its
130 +// TLS primitives. So, we build it manually by inserting a 130 +// TLS primitives. So, we build it manually by inserting a
131 +// function to be called on each thread's exit. 131 +// function to be called on each thread's exit.
132 +// This magic is from http://www.codeproject.com/threads/tls.asp 132 +// This magic is from http://www.codeproject.com/threads/tls.asp
133 +// and it works for VC++ 7.0 and later. 133 +// and it works for VC++ 7.0 and later.
134 + 134 +
135 +// Force a reference to _tls_used to make the linker create the TLS directory
136 +// if it's not already there. (e.g. if __declspec(thread) is not used).
137 +// Force a reference to p_thread_callback_nspr to prevent whole program
138 +// optimization from discarding the variable.
135 +#ifdef _WIN64 139 +#ifdef _WIN64
136 + 140 +
137 +// This makes the linker create the TLS directory if it's not already
138 +// there. (e.g. if __declspec(thread) is not used).
139 +#pragma comment(linker, "/INCLUDE:_tls_used") 141 +#pragma comment(linker, "/INCLUDE:_tls_used")
142 +#pragma comment(linker, "/INCLUDE:p_thread_callback_nspr")
140 + 143 +
141 +#else // _WIN64 144 +#else // _WIN64
142 + 145 +
143 +// This makes the linker create the TLS directory if it's not already
144 +// there. (e.g. if __declspec(thread) is not used).
145 +#pragma comment(linker, "/INCLUDE:__tls_used") 146 +#pragma comment(linker, "/INCLUDE:__tls_used")
147 +#pragma comment(linker, "/INCLUDE:_p_thread_callback_nspr")
146 + 148 +
147 +#endif // _WIN64 149 +#endif // _WIN64
148 + 150 +
149 +// Static callback function to call with each thread termination. 151 +// Static callback function to call with each thread termination.
150 +static void NTAPI PR_OnThreadExit(PVOID module, DWORD reason, PVOID reserved) 152 +static void NTAPI PR_OnThreadExit(PVOID module, DWORD reason, PVOID reserved)
151 +{ 153 +{
152 +PRThread *me; 154 +PRThread *me;
153 + 155 +
154 + switch (reason) { 156 + switch (reason) {
155 + case DLL_PROCESS_ATTACH: 157 + case DLL_PROCESS_ATTACH:
(...skipping 15 matching lines...) Expand all
171 +// .CRT$XLA to .CRT$XLZ is an array of PIMAGE_TLS_CALLBACK pointers that are 173 +// .CRT$XLA to .CRT$XLZ is an array of PIMAGE_TLS_CALLBACK pointers that are
172 +// called automatically by the OS loader code (not the CRT) when the module is 174 +// called automatically by the OS loader code (not the CRT) when the module is
173 +// loaded and on thread creation. They are NOT called if the module has been 175 +// loaded and on thread creation. They are NOT called if the module has been
174 +// loaded by a LoadLibrary() call. It must have implicitly been loaded at 176 +// loaded by a LoadLibrary() call. It must have implicitly been loaded at
175 +// process startup. 177 +// process startup.
176 +// By implicitly loaded, I mean that it is directly referenced by the main EXE 178 +// By implicitly loaded, I mean that it is directly referenced by the main EXE
177 +// or by one of its dependent DLLs. Delay-loaded DLL doesn't count as being 179 +// or by one of its dependent DLLs. Delay-loaded DLL doesn't count as being
178 +// implicitly loaded. 180 +// implicitly loaded.
179 +// 181 +//
180 +// See VC\crt\src\tlssup.c for reference. 182 +// See VC\crt\src\tlssup.c for reference.
183 +
184 +// The linker must not discard p_thread_callback_nspr. (We force a reference
185 +// to this variable with a linker /INCLUDE:symbol pragma to ensure that.) If
186 +// this variable is discarded, the PR_OnThreadExit function will never be
187 +// called.
181 +#ifdef _WIN64 188 +#ifdef _WIN64
182 + 189 +
183 +// .CRT section is merged with .rdata on x64 so it must be constant data. 190 +// .CRT section is merged with .rdata on x64 so it must be constant data.
184 +#pragma const_seg(".CRT$XLB") 191 +#pragma const_seg(".CRT$XLB")
185 +// When defining a const variable, it must have external linkage to be sure the 192 +// When defining a const variable, it must have external linkage to be sure the
186 +// linker doesn't discard it. If this value is discarded, the PR_OnThreadExit 193 +// linker doesn't discard it.
187 +// function will never be called. 194 +extern const PIMAGE_TLS_CALLBACK p_thread_callback_nspr;
188 +extern const PIMAGE_TLS_CALLBACK p_thread_callback; 195 +const PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit;
189 +const PIMAGE_TLS_CALLBACK p_thread_callback = PR_OnThreadExit;
190 + 196 +
191 +// Reset the default section. 197 +// Reset the default section.
192 +#pragma const_seg() 198 +#pragma const_seg()
193 + 199 +
194 +#else // _WIN64 200 +#else // _WIN64
195 + 201 +
196 +#pragma data_seg(".CRT$XLB") 202 +#pragma data_seg(".CRT$XLB")
197 +PIMAGE_TLS_CALLBACK p_thread_callback = PR_OnThreadExit; 203 +PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit;
198 + 204 +
199 +// Reset the default section. 205 +// Reset the default section.
200 +#pragma data_seg() 206 +#pragma data_seg()
201 + 207 +
202 +#endif // _WIN64 208 +#endif // _WIN64
OLDNEW
« no previous file with comments | « nss/patches/nspr-attach-as-system-thread.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698