Mercurial > trustbridge > nss-cmake-static
comparison patches/nspr-static.patch @ 0:1e5118fa0cb1
This is NSS with a Cmake Buildsyste
To compile a static NSS library for Windows we've used the
Chromium-NSS fork and added a Cmake buildsystem to compile
it statically for Windows. See README.chromium for chromium
changes and README.trustbridge for our modifications.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 28 Jul 2014 10:47:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1e5118fa0cb1 |
---|---|
1 Index: mozilla/nsprpub/pr/include/prtypes.h | |
2 =================================================================== | |
3 RCS file: /cvsroot/mozilla/nsprpub/pr/include/prtypes.h,v | |
4 retrieving revision 3.52 | |
5 diff -p -u -8 -r3.52 prtypes.h | |
6 --- mozilla/nsprpub/pr/include/prtypes.h 7 Dec 2012 21:13:41 -0000 3.52 | |
7 +++ mozilla/nsprpub/pr/include/prtypes.h 29 Jan 2013 01:15:02 -0000 | |
8 @@ -43,17 +43,33 @@ | |
9 ** Example: | |
10 ** in dowhim.h | |
11 ** PR_EXTERN( void ) DoWhatIMean( void ); | |
12 ** in dowhim.c | |
13 ** PR_IMPLEMENT( void ) DoWhatIMean( void ) { return; } | |
14 ** | |
15 ** | |
16 ***********************************************************************/ | |
17 -#if defined(WIN32) | |
18 +#if defined(NSPR_STATIC) | |
19 + | |
20 +#define PR_EXPORT(__type) extern __type | |
21 +#define PR_EXPORT_DATA(__type) extern __type | |
22 +#define PR_IMPORT(__type) extern __type | |
23 +#define PR_IMPORT_DATA(__type) extern __type | |
24 + | |
25 +#define PR_EXTERN(__type) extern __type | |
26 +#define PR_IMPLEMENT(__type) __type | |
27 +#define PR_EXTERN_DATA(__type) extern __type | |
28 +#define PR_IMPLEMENT_DATA(__type) __type | |
29 + | |
30 +#define PR_CALLBACK | |
31 +#define PR_CALLBACK_DECL | |
32 +#define PR_STATIC_CALLBACK(__x) static __x | |
33 + | |
34 +#elif defined(WIN32) | |
35 | |
36 #define PR_EXPORT(__type) extern __declspec(dllexport) __type | |
37 #define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type | |
38 #define PR_IMPORT(__type) __declspec(dllimport) __type | |
39 #define PR_IMPORT_DATA(__type) __declspec(dllimport) __type | |
40 | |
41 #define PR_EXTERN(__type) extern __declspec(dllexport) __type | |
42 #define PR_IMPLEMENT(__type) __declspec(dllexport) __type | |
43 Index: mozilla/nsprpub/pr/src/md/windows/w95dllmain.c | |
44 =================================================================== | |
45 RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/windows/w95dllmain.c,v | |
46 retrieving revision 3.9 | |
47 diff -p -u -8 -r3.9 w95dllmain.c | |
48 --- mozilla/nsprpub/pr/src/md/windows/w95dllmain.c 6 Mar 2012 13:14:17 -0000 3.9 | |
49 +++ mozilla/nsprpub/pr/src/md/windows/w95dllmain.c 29 Jan 2013 01:15:02 -0000 | |
50 @@ -1,13 +1,15 @@ | |
51 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | |
52 /* This Source Code Form is subject to the terms of the Mozilla Public | |
53 * License, v. 2.0. If a copy of the MPL was not distributed with this | |
54 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
55 | |
56 +#ifndef NSPR_STATIC /* See the end of w95thred.c. */ | |
57 + | |
58 /* | |
59 * The DLL entry point (DllMain) for NSPR. | |
60 * | |
61 * This is used to detach threads that were automatically attached by | |
62 * nspr. | |
63 */ | |
64 | |
65 #include <windows.h> | |
66 @@ -32,8 +34,10 @@ PRThread *me; | |
67 _PRI_DetachThread(); | |
68 } | |
69 break; | |
70 case DLL_PROCESS_DETACH: | |
71 break; | |
72 } | |
73 return TRUE; | |
74 } | |
75 + | |
76 +#endif | |
77 Index: mozilla/nsprpub/pr/src/md/windows/w95thred.c | |
78 =================================================================== | |
79 RCS file: /cvsroot/mozilla/nsprpub/pr/src/md/windows/w95thred.c,v | |
80 retrieving revision 3.22 | |
81 diff -p -u -8 -r3.22 w95thred.c | |
82 --- mozilla/nsprpub/pr/src/md/windows/w95thred.c 13 Jun 2012 02:17:05 -0000 3.22 | |
83 +++ mozilla/nsprpub/pr/src/md/windows/w95thred.c 29 Jan 2013 01:15:02 -0000 | |
84 @@ -313,8 +313,125 @@ PRThread *thread; | |
85 | |
86 if (NULL == thread) { | |
87 thread = _PRI_AttachThread( | |
88 PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL, 0); | |
89 } | |
90 PR_ASSERT(thread != NULL); | |
91 return thread; | |
92 } | |
93 + | |
94 +#ifdef NSPR_STATIC | |
95 + | |
96 +// The following code is from Chromium src/base/thread_local_storage_win.cc, | |
97 +// r11329. | |
98 + | |
99 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
100 +// | |
101 +// Redistribution and use in source and binary forms, with or without | |
102 +// modification, are permitted provided that the following conditions are | |
103 +// met: | |
104 +// | |
105 +// * Redistributions of source code must retain the above copyright | |
106 +// notice, this list of conditions and the following disclaimer. | |
107 +// * Redistributions in binary form must reproduce the above | |
108 +// copyright notice, this list of conditions and the following disclaimer | |
109 +// in the documentation and/or other materials provided with the | |
110 +// distribution. | |
111 +// * Neither the name of Google Inc. nor the names of its | |
112 +// contributors may be used to endorse or promote products derived from | |
113 +// this software without specific prior written permission. | |
114 +// | |
115 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
116 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
117 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
118 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
119 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
120 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
121 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
122 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
123 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
124 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
125 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
126 + | |
127 +// Thread Termination Callbacks. | |
128 +// Windows doesn't support a per-thread destructor with its | |
129 +// TLS primitives. So, we build it manually by inserting a | |
130 +// function to be called on each thread's exit. | |
131 +// This magic is from http://www.codeproject.com/threads/tls.asp | |
132 +// and it works for VC++ 7.0 and later. | |
133 + | |
134 +// Force a reference to _tls_used to make the linker create the TLS directory | |
135 +// if it's not already there. (e.g. if __declspec(thread) is not used). | |
136 +// Force a reference to p_thread_callback_nspr to prevent whole program | |
137 +// optimization from discarding the variable. | |
138 +#ifdef _WIN64 | |
139 + | |
140 +#pragma comment(linker, "/INCLUDE:_tls_used") | |
141 +#pragma comment(linker, "/INCLUDE:p_thread_callback_nspr") | |
142 + | |
143 +#else // _WIN64 | |
144 + | |
145 +#pragma comment(linker, "/INCLUDE:__tls_used") | |
146 +#pragma comment(linker, "/INCLUDE:_p_thread_callback_nspr") | |
147 + | |
148 +#endif // _WIN64 | |
149 + | |
150 +// Static callback function to call with each thread termination. | |
151 +static void NTAPI PR_OnThreadExit(PVOID module, DWORD reason, PVOID reserved) | |
152 +{ | |
153 +PRThread *me; | |
154 + | |
155 + switch (reason) { | |
156 + case DLL_PROCESS_ATTACH: | |
157 + break; | |
158 + case DLL_THREAD_ATTACH: | |
159 + break; | |
160 + case DLL_THREAD_DETACH: | |
161 + if (_pr_initialized) { | |
162 + me = _MD_GET_ATTACHED_THREAD(); | |
163 + if ((me != NULL) && (me->flags & _PR_ATTACHED)) | |
164 + _PRI_DetachThread(); | |
165 + } | |
166 + break; | |
167 + case DLL_PROCESS_DETACH: | |
168 + break; | |
169 + } | |
170 +} | |
171 + | |
172 +// .CRT$XLA to .CRT$XLZ is an array of PIMAGE_TLS_CALLBACK pointers that are | |
173 +// called automatically by the OS loader code (not the CRT) when the module is | |
174 +// loaded and on thread creation. They are NOT called if the module has been | |
175 +// loaded by a LoadLibrary() call. It must have implicitly been loaded at | |
176 +// process startup. | |
177 +// By implicitly loaded, I mean that it is directly referenced by the main EXE | |
178 +// or by one of its dependent DLLs. Delay-loaded DLL doesn't count as being | |
179 +// implicitly loaded. | |
180 +// | |
181 +// See VC\crt\src\tlssup.c for reference. | |
182 + | |
183 +// The linker must not discard p_thread_callback_nspr. (We force a reference | |
184 +// to this variable with a linker /INCLUDE:symbol pragma to ensure that.) If | |
185 +// this variable is discarded, the PR_OnThreadExit function will never be | |
186 +// called. | |
187 +#ifdef _WIN64 | |
188 + | |
189 +// .CRT section is merged with .rdata on x64 so it must be constant data. | |
190 +#pragma const_seg(".CRT$XLB") | |
191 +// When defining a const variable, it must have external linkage to be sure the | |
192 +// linker doesn't discard it. | |
193 +extern const PIMAGE_TLS_CALLBACK p_thread_callback_nspr; | |
194 +const PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit; | |
195 + | |
196 +// Reset the default section. | |
197 +#pragma const_seg() | |
198 + | |
199 +#else // _WIN64 | |
200 + | |
201 +#pragma data_seg(".CRT$XLB") | |
202 +PIMAGE_TLS_CALLBACK p_thread_callback_nspr = PR_OnThreadExit; | |
203 + | |
204 +// Reset the default section. | |
205 +#pragma data_seg() | |
206 + | |
207 +#endif // _WIN64 | |
208 + | |
209 +#endif // NSPR_STATIC |