summarylogtreecommitdiffstats
path: root/Bug-1269171.patch
blob: e67672adb89c612f8cd0c2dae0dcf722627c1c3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
diff --git a/config/gcc-stl-wrapper.template.h b/config/gcc-stl-wrapper.template.h
--- a/config/gcc-stl-wrapper.template.h
+++ b/config/gcc-stl-wrapper.template.h
@@ -22,21 +22,34 @@
 #define NOMINMAX 1
 #endif
 
+#if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
+// Enable checked iterators and other goodies
+//
+// FIXME/bug 551254: gcc's debug STL implementation requires -frtti.
+// Figure out how to resolve this with -fno-rtti.  Maybe build with
+// -frtti in DEBUG builds?
+//
+//  # define _GLIBCXX_DEBUG 1
+#endif
+
 // Don't include mozalloc for cstdlib. See bug 1245076.
 #ifndef moz_dont_include_mozalloc_for_cstdlib
 #  define moz_dont_include_mozalloc_for_cstdlib
 #endif
-#ifndef moz_dont_include_mozalloc_for_${HEADER}
-// mozalloc.h wants <new>; break the cycle by always explicitly
-// including <new> here.  NB: this is a tad sneaky.  Sez the gcc docs:
-//
-//    `#include_next' does not distinguish between <file> and "file"
-//    inclusion, nor does it check that the file you specify has the
-//    same name as the current file. It simply looks for the file
-//    named, starting with the directory in the search path after the
-//    one where the current file was found.
-#  include_next <new>
 
+// Include mozalloc after the STL header and all other headers it includes
+// have been preprocessed.
+#if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
+    !defined(moz_dont_include_mozalloc_for_${HEADER})
+#  define MOZ_INCLUDE_MOZALLOC_H
+#  define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
+#endif
+
+#pragma GCC visibility push(default)
+#include_next <${HEADER}>
+#pragma GCC visibility pop
+
+#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
 // See if we're in code that can use mozalloc.  NB: this duplicates
 // code in nscore.h because nscore.h pulls in prtypes.h, and chromium
 // can't build with that being included before base/basictypes.h.
@@ -45,23 +58,8 @@
 #  else
 #    error "STL code can only be used with infallible ::operator new()"
 #  endif
-
-#endif
-
-#if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
-// Enable checked iterators and other goodies
-//
-// FIXME/bug 551254: gcc's debug STL implementation requires -frtti.
-// Figure out how to resolve this with -fno-rtti.  Maybe build with
-// -frtti in DEBUG builds?
-//
-//  # define _GLIBCXX_DEBUG 1
 #endif
 
-#pragma GCC visibility push(default)
-#include_next <${HEADER}>
-#pragma GCC visibility pop
-
 // gcc calls a __throw_*() function from bits/functexcept.h when it
 // wants to "throw an exception".  functexcept exists nominally to
 // support -fno-exceptions, but since we'll always use the system
diff --git a/config/make-stl-wrappers.py b/config/make-stl-wrappers.py
--- a/config/make-stl-wrappers.py
+++ b/config/make-stl-wrappers.py
@@ -25,28 +25,26 @@
 def is_comment(line):
     return re.match(r'\s*#.*', line)
 
 def main(outdir, compiler, template_file, header_list_file):
     if not os.path.isdir(outdir):
         os.mkdir(outdir)
 
     template = open(template_file, 'r').read()
-    path_to_new = header_path('new', compiler)
 
     for header in open(header_list_file, 'r'):
         header = header.rstrip()
         if 0 == len(header) or is_comment(header):
             continue
 
         path = header_path(header, compiler)
         with FileAvoidWrite(os.path.join(outdir, header)) as f:
             f.write(string.Template(template).substitute(HEADER=header,
-                                                         HEADER_PATH=path,
-                                                         NEW_HEADER_PATH=path_to_new))
+                                                         HEADER_PATH=path))
 
 
 if __name__ == '__main__':
     if 5 != len(sys.argv):
         print("""Usage:
   python {0} OUT_DIR ('msvc'|'gcc') TEMPLATE_FILE HEADER_LIST_FILE
 """.format(sys.argv[0]), file=sys.stderr)
         sys.exit(1)
diff --git a/memory/mozalloc/mozalloc.h b/memory/mozalloc/mozalloc.h
--- a/memory/mozalloc/mozalloc.h
+++ b/memory/mozalloc/mozalloc.h
@@ -7,20 +7,27 @@
 
 #ifndef mozilla_mozalloc_h
 #define mozilla_mozalloc_h
 
 /*
  * https://bugzilla.mozilla.org/show_bug.cgi?id=427099
  */
 
-#include <stdlib.h>
-#include <string.h>
 #if defined(__cplusplus)
 #  include <new>
+// Since libstdc++ 6, including the C headers (e.g. stdlib.h) instead of the
+// corresponding C++ header (e.g. cstdlib) can cause confusion in C++ code
+// using things defined there. Specifically, with stdlib.h, the use of abs()
+// in gfx/graphite2/src/inc/UtfCodec.h somehow ends up picking the wrong abs()
+#  include <cstdlib>
+#  include <cstring>
+#else
+#  include <stdlib.h>
+#  include <string.h>
 #endif
 
 #if defined(__cplusplus)
 #include "mozilla/fallible.h"
 #include "mozilla/TemplateLib.h"
 #endif
 #include "mozilla/Attributes.h"
 #include "mozilla/Types.h"