]> git.pld-linux.org Git - packages/icedove.git/blame - mozilla-1269171-badalloc.patch
- up to 45.8.0
[packages/icedove.git] / mozilla-1269171-badalloc.patch
CommitLineData
7a5e9406
JR
1From: Jens Lody <fedora@jenslody.de>
2Date: Thu, 16 Feb 2017 09:31:56 +0100
3Subject: Backport of fix for mozilla-bug 1269171, needed for gcc7.
4
5diff --git a/mozilla/config/gcc-stl-wrapper.template.h b/mozilla/config/gcc-stl-wrapper.template.h
6--- a/mozilla/config/gcc-stl-wrapper.template.h
7+++ b/mozilla/config/gcc-stl-wrapper.template.h
8@@ -17,25 +17,6 @@
9 // Silence "warning: #include_next is a GCC extension"
10 #pragma GCC system_header
11
12-// mozalloc.h wants <new>; break the cycle by always explicitly
13-// including <new> here. NB: this is a tad sneaky. Sez the gcc docs:
14-//
15-// `#include_next' does not distinguish between <file> and "file"
16-// inclusion, nor does it check that the file you specify has the
17-// same name as the current file. It simply looks for the file
18-// named, starting with the directory in the search path after the
19-// one where the current file was found.
20-#include_next <new>
21-
22-// See if we're in code that can use mozalloc. NB: this duplicates
23-// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
24-// can't build with that being included before base/basictypes.h.
25-#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
26-# include "mozilla/mozalloc.h"
27-#else
28-# error "STL code can only be used with infallible ::operator new()"
29-#endif
30-
31 #if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
32 // Enable checked iterators and other goodies
33 //
34@@ -46,10 +27,34 @@
35 // # define _GLIBCXX_DEBUG 1
36 #endif
37
38+// Don't include mozalloc for cstdlib. See bug 1245076.
39+#ifndef moz_dont_include_mozalloc_for_cstdlib
40+# define moz_dont_include_mozalloc_for_cstdlib
41+#endif
42+
43+// Include mozalloc after the STL header and all other headers it includes
44+// have been preprocessed.
45+#if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
46+ !defined(moz_dont_include_mozalloc_for_${HEADER})
47+# define MOZ_INCLUDE_MOZALLOC_H
48+# define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
49+#endif
50+
51 #pragma GCC visibility push(default)
52 #include_next <${HEADER}>
53 #pragma GCC visibility pop
54
55+#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
56+// See if we're in code that can use mozalloc. NB: this duplicates
57+// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
58+// can't build with that being included before base/basictypes.h.
59+# if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
60+# include "mozilla/mozalloc.h"
61+# else
62+# error "STL code can only be used with infallible ::operator new()"
63+# endif
64+#endif
65+
66 // gcc calls a __throw_*() function from bits/functexcept.h when it
67 // wants to "throw an exception". functexcept exists nominally to
68 // support -fno-exceptions, but since we'll always use the system
69--- a/mozilla/config/make-stl-wrappers.py
70+++ b/mozilla/config/make-stl-wrappers.py
71@@ -25,28 +25,26 @@ def header_path(header, compiler):
72 def is_comment(line):
73 return re.match(r'\s*#.*', line)
74
75 def main(outdir, compiler, template_file, header_list_file):
76 if not os.path.isdir(outdir):
77 os.mkdir(outdir)
78
79 template = open(template_file, 'r').read()
80- path_to_new = header_path('new', compiler)
81
82 for header in open(header_list_file, 'r'):
83 header = header.rstrip()
84 if 0 == len(header) or is_comment(header):
85 continue
86
87 path = header_path(header, compiler)
88 with FileAvoidWrite(os.path.join(outdir, header)) as f:
89 f.write(string.Template(template).substitute(HEADER=header,
90- HEADER_PATH=path,
91- NEW_HEADER_PATH=path_to_new))
92+ HEADER_PATH=path))
93
94
95 if __name__ == '__main__':
96 if 5 != len(sys.argv):
97 print("""Usage:
98 python {0} OUT_DIR ('msvc'|'gcc') TEMPLATE_FILE HEADER_LIST_FILE
99 """.format(sys.argv[0]), file=sys.stderr)
100 sys.exit(1)
101diff --git a/mozilla/config/msvc-stl-wrapper.template.h b/mozilla/config/msvc-stl-wrapper.template.h
102--- a/mozilla/config/msvc-stl-wrapper.template.h
103+++ b/mozilla/config/msvc-stl-wrapper.template.h
104@@ -3,45 +3,33 @@
105 */
106 /* This Source Code Form is subject to the terms of the Mozilla Public
107 * License, v. 2.0. If a copy of the MPL was not distributed with this
108 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
109
110 #ifndef mozilla_${HEADER}_h
111 #define mozilla_${HEADER}_h
112
113-#ifndef MOZ_HAVE_INCLUDED_ALLOC
114-#define MOZ_HAVE_INCLUDED_ALLOC
115-
116 #if _HAS_EXCEPTIONS
117 # error "STL code can only be used with -fno-exceptions"
118 #endif
119
120+// Include mozalloc after the STL header and all other headers it includes
121+// have been preprocessed.
122+#if !defined(MOZ_INCLUDE_MOZALLOC_H)
123+# define MOZ_INCLUDE_MOZALLOC_H
124+# define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
125+#endif
126+
127 // Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k
128 // CRT doesn't export std::_Throw(). So we define it.
129 #ifndef mozilla_Throw_h
130 # include "mozilla/throw_msvc.h"
131 #endif
132
133-// Code might include <new> before other wrapped headers, but <new>
134-// includes <exception> and so we want to wrap it. But mozalloc.h
135-// wants <new> also, so we break the cycle by always explicitly
136-// including <new> here.
137-#include <${NEW_HEADER_PATH}>
138-
139-// See if we're in code that can use mozalloc. NB: this duplicates
140-// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
141-// can't build with that being included before base/basictypes.h.
142-#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
143-# include "mozilla/mozalloc.h"
144-#else
145-# error "STL code can only be used with infallible ::operator new()"
146-#endif
147-#endif /* MOZ_HAVE_INCLUDED_ALLOC */
148-
149 #ifdef _DEBUG
150 // From
151 // http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx
152 // and
153 // http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx
154 // there appear to be two types of STL container checking. The
155 // former is enabled by -D_DEBUG (which is implied by -MDd or -MTd), and
156 // looks to be full generation/mutation checked iterators as done by
157@@ -70,9 +58,20 @@
158 // but that's OK because we're not throwing them.
159 #pragma warning( push )
160 #pragma warning( disable : 4275 4530 )
161
162 #include <${HEADER_PATH}>
163
164 #pragma warning( pop )
165
166+#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
167+// See if we're in code that can use mozalloc. NB: this duplicates
168+// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
169+// can't build with that being included before base/basictypes.h.
170+# if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
171+# include "mozilla/mozalloc.h"
172+# else
173+# error "STL code can only be used with infallible ::operator new()"
174+# endif
175+#endif
176+
177 #endif // if mozilla_${HEADER}_h
178diff --git a/mozilla/memory/mozalloc/mozalloc.h b/mozilla/memory/mozalloc/mozalloc.h
179--- a/mozilla/memory/mozalloc/mozalloc.h
180+++ b/mozilla/memory/mozalloc/mozalloc.h
181@@ -7,20 +7,27 @@
182
183 #ifndef mozilla_mozalloc_h
184 #define mozilla_mozalloc_h
185
186 /*
187 * https://bugzilla.mozilla.org/show_bug.cgi?id=427099
188 */
189
190-#include <stdlib.h>
191-#include <string.h>
192 #if defined(__cplusplus)
193 # include <new>
194+// Since libstdc++ 6, including the C headers (e.g. stdlib.h) instead of the
195+// corresponding C++ header (e.g. cstdlib) can cause confusion in C++ code
196+// using things defined there. Specifically, with stdlib.h, the use of abs()
197+// in gfx/graphite2/src/inc/UtfCodec.h somehow ends up picking the wrong abs()
198+# include <cstdlib>
199+# include <cstring>
200+#else
201+# include <stdlib.h>
202+# include <string.h>
203 #endif
204
205 #if defined(__cplusplus)
206 #include "mozilla/fallible.h"
207 #include "mozilla/TemplateLib.h"
208 #endif
209 #include "mozilla/Attributes.h"
210 #include "mozilla/Types.h"
211
212
This page took 0.05011 seconds and 4 git commands to generate.