View | Details | Raw Unified | Return to bug 212431 | Differences between
and this patch

Collapse All | Expand All

(-)config/gcc-stl-wrapper.template.h (-26 / +24 lines)
Lines 12-67 Link Here
12
// compiling ObjC.
12
// compiling ObjC.
13
#if defined(__EXCEPTIONS) && __EXCEPTIONS && !(__OBJC__ && __GNUC__ && XP_IOS)
13
#if defined(__EXCEPTIONS) && __EXCEPTIONS && !(__OBJC__ && __GNUC__ && XP_IOS)
14
#  error "STL code can only be used with -fno-exceptions"
14
#  error "STL code can only be used with -fno-exceptions"
15
#endif
15
#endif
16
16
17
// Silence "warning: #include_next is a GCC extension"
17
// Silence "warning: #include_next is a GCC extension"
18
#pragma GCC system_header
18
#pragma GCC system_header
19
19
20
// Don't include mozalloc for cstdlib. See bug 1245076.
21
#ifndef moz_dont_include_mozalloc_for_cstdlib
22
#  define moz_dont_include_mozalloc_for_cstdlib
23
#endif
24
#ifndef moz_dont_include_mozalloc_for_${HEADER}
25
// mozalloc.h wants <new>; break the cycle by always explicitly
26
// including <new> here.  NB: this is a tad sneaky.  Sez the gcc docs:
27
//
28
//    `#include_next' does not distinguish between <file> and "file"
29
//    inclusion, nor does it check that the file you specify has the
30
//    same name as the current file. It simply looks for the file
31
//    named, starting with the directory in the search path after the
32
//    one where the current file was found.
33
#  include_next <new>
34
35
// See if we're in code that can use mozalloc.  NB: this duplicates
36
// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
37
// can't build with that being included before base/basictypes.h.
38
#  if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
39
#    include "mozilla/mozalloc.h"
40
#  else
41
#    error "STL code can only be used with infallible ::operator new()"
42
#  endif
43
44
#endif
45
46
#if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
20
#if defined(DEBUG) && !defined(_GLIBCXX_DEBUG)
47
// Enable checked iterators and other goodies
21
// Enable checked iterators and other goodies
48
//
22
//
49
// FIXME/bug 551254: gcc's debug STL implementation requires -frtti.
23
// FIXME/bug 551254: gcc's debug STL implementation requires -frtti.
50
// Figure out how to resolve this with -fno-rtti.  Maybe build with
24
// Figure out how to resolve this with -fno-rtti.  Maybe build with
51
// -frtti in DEBUG builds?
25
// -frtti in DEBUG builds?
52
//
26
//
53
//  # define _GLIBCXX_DEBUG 1
27
//  # define _GLIBCXX_DEBUG 1
54
#endif
28
#endif
55
29
30
// Don't include mozalloc for cstdlib. See bug 1245076.
31
#ifndef moz_dont_include_mozalloc_for_cstdlib
32
#  define moz_dont_include_mozalloc_for_cstdlib
33
#endif
34
35
// Include mozalloc after the STL header and all other headers it includes
36
// have been preprocessed.
37
#if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
38
    !defined(moz_dont_include_mozalloc_for_${HEADER})
39
#  define MOZ_INCLUDE_MOZALLOC_H
40
#  define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
41
#endif
42
56
#pragma GCC visibility push(default)
43
#pragma GCC visibility push(default)
57
#include_next <${HEADER}>
44
#include_next <${HEADER}>
58
#pragma GCC visibility pop
45
#pragma GCC visibility pop
59
46
47
#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
48
// See if we're in code that can use mozalloc.  NB: this duplicates
49
// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
50
// can't build with that being included before base/basictypes.h.
51
#  if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
52
#    include "mozilla/mozalloc.h"
53
#  else
54
#    error "STL code can only be used with infallible ::operator new()"
55
#  endif
56
#endif
57
60
// gcc calls a __throw_*() function from bits/functexcept.h when it
58
// gcc calls a __throw_*() function from bits/functexcept.h when it
61
// wants to "throw an exception".  functexcept exists nominally to
59
// wants to "throw an exception".  functexcept exists nominally to
62
// support -fno-exceptions, but since we'll always use the system
60
// support -fno-exceptions, but since we'll always use the system
63
// libstdc++, and it's compiled with exceptions, then in practice
61
// libstdc++, and it's compiled with exceptions, then in practice
64
// these __throw_*() functions will always throw exceptions (shades of
62
// these __throw_*() functions will always throw exceptions (shades of
65
// -fshort-wchar).  We don't want that and so define our own inlined
63
// -fshort-wchar).  We don't want that and so define our own inlined
66
// __throw_*().
64
// __throw_*().
67
#ifndef mozilla_throw_gcc_h
65
#ifndef mozilla_throw_gcc_h
(-)config/make-stl-wrappers.py (-3 / +1 lines)
Lines 25-52 def header_path(header, compiler): Link Here
25
def is_comment(line):
25
def is_comment(line):
26
    return re.match(r'\s*#.*', line)
26
    return re.match(r'\s*#.*', line)
27
27
28
def main(outdir, compiler, template_file, header_list_file):
28
def main(outdir, compiler, template_file, header_list_file):
29
    if not os.path.isdir(outdir):
29
    if not os.path.isdir(outdir):
30
        os.mkdir(outdir)
30
        os.mkdir(outdir)
31
31
32
    template = open(template_file, 'r').read()
32
    template = open(template_file, 'r').read()
33
    path_to_new = header_path('new', compiler)
34
33
35
    for header in open(header_list_file, 'r'):
34
    for header in open(header_list_file, 'r'):
36
        header = header.rstrip()
35
        header = header.rstrip()
37
        if 0 == len(header) or is_comment(header):
36
        if 0 == len(header) or is_comment(header):
38
            continue
37
            continue
39
38
40
        path = header_path(header, compiler)
39
        path = header_path(header, compiler)
41
        with FileAvoidWrite(os.path.join(outdir, header)) as f:
40
        with FileAvoidWrite(os.path.join(outdir, header)) as f:
42
            f.write(string.Template(template).substitute(HEADER=header,
41
            f.write(string.Template(template).substitute(HEADER=header,
43
                                                         HEADER_PATH=path,
42
                                                         HEADER_PATH=path))
44
                                                         NEW_HEADER_PATH=path_to_new))
45
43
46
44
47
if __name__ == '__main__':
45
if __name__ == '__main__':
48
    if 5 != len(sys.argv):
46
    if 5 != len(sys.argv):
49
        print("""Usage:
47
        print("""Usage:
50
  python {0} OUT_DIR ('msvc'|'gcc') TEMPLATE_FILE HEADER_LIST_FILE
48
  python {0} OUT_DIR ('msvc'|'gcc') TEMPLATE_FILE HEADER_LIST_FILE
51
""".format(sys.argv[0]), file=sys.stderr)
49
""".format(sys.argv[0]), file=sys.stderr)
52
        sys.exit(1)
50
        sys.exit(1)
(-)config/msvc-stl-wrapper.template.h (-19 / +18 lines)
Lines 3-47 Link Here
3
 */
3
 */
4
/* This Source Code Form is subject to the terms of the Mozilla Public
4
/* This Source Code Form is subject to the terms of the Mozilla Public
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * License, v. 2.0. If a copy of the MPL was not distributed with this
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
7
8
#ifndef mozilla_${HEADER}_h
8
#ifndef mozilla_${HEADER}_h
9
#define mozilla_${HEADER}_h
9
#define mozilla_${HEADER}_h
10
10
11
#ifndef MOZ_HAVE_INCLUDED_ALLOC
12
#define MOZ_HAVE_INCLUDED_ALLOC
13
14
#if _HAS_EXCEPTIONS
11
#if _HAS_EXCEPTIONS
15
#  error "STL code can only be used with -fno-exceptions"
12
#  error "STL code can only be used with -fno-exceptions"
16
#endif
13
#endif
17
14
15
// Include mozalloc after the STL header and all other headers it includes
16
// have been preprocessed.
17
#if !defined(MOZ_INCLUDE_MOZALLOC_H)
18
#  define MOZ_INCLUDE_MOZALLOC_H
19
#  define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
20
#endif
21
18
// Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k
22
// Code built with !_HAS_EXCEPTIONS calls std::_Throw(), but the win2k
19
// CRT doesn't export std::_Throw().  So we define it.
23
// CRT doesn't export std::_Throw().  So we define it.
20
#ifndef mozilla_Throw_h
24
#ifndef mozilla_Throw_h
21
#  include "mozilla/throw_msvc.h"
25
#  include "mozilla/throw_msvc.h"
22
#endif
26
#endif
23
27
24
// Code might include <new> before other wrapped headers, but <new>
25
// includes <exception> and so we want to wrap it.  But mozalloc.h
26
// wants <new> also, so we break the cycle by always explicitly
27
// including <new> here.
28
#include <${NEW_HEADER_PATH}>
29
30
// See if we're in code that can use mozalloc.  NB: this duplicates
31
// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
32
// can't build with that being included before base/basictypes.h.
33
#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
34
#  include "mozilla/mozalloc.h"
35
#else
36
#  error "STL code can only be used with infallible ::operator new()"
37
#endif
38
#endif /* MOZ_HAVE_INCLUDED_ALLOC */
39
40
#ifdef _DEBUG
28
#ifdef _DEBUG
41
// From
29
// From
42
//   http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx
30
//   http://msdn.microsoft.com/en-us/library/aa985982%28VS.80%29.aspx
43
// and
31
// and
44
//   http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx
32
//   http://msdn.microsoft.com/en-us/library/aa985965%28VS.80%29.aspx
45
// there appear to be two types of STL container checking.  The
33
// there appear to be two types of STL container checking.  The
46
// former is enabled by -D_DEBUG (which is implied by -MDd or -MTd), and
34
// former is enabled by -D_DEBUG (which is implied by -MDd or -MTd), and
47
// looks to be full generation/mutation checked iterators as done by
35
// looks to be full generation/mutation checked iterators as done by
Lines 70-78 Link Here
70
//        but that's OK because we're not throwing them.
58
//        but that's OK because we're not throwing them.
71
#pragma warning( push )
59
#pragma warning( push )
72
#pragma warning( disable : 4275 4530 )
60
#pragma warning( disable : 4275 4530 )
73
61
74
#include <${HEADER_PATH}>
62
#include <${HEADER_PATH}>
75
63
76
#pragma warning( pop )
64
#pragma warning( pop )
77
65
66
#ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
67
// See if we're in code that can use mozalloc.  NB: this duplicates
68
// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
69
// can't build with that being included before base/basictypes.h.
70
#  if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
71
#    include "mozilla/mozalloc.h"
72
#  else
73
#    error "STL code can only be used with infallible ::operator new()"
74
#  endif
75
#endif
76
78
#endif  // if mozilla_${HEADER}_h
77
#endif  // if mozilla_${HEADER}_h
(-)memory/mozalloc/mozalloc.h (-2 / +9 lines)
Lines 7-26 Link Here
7
7
8
#ifndef mozilla_mozalloc_h
8
#ifndef mozilla_mozalloc_h
9
#define mozilla_mozalloc_h
9
#define mozilla_mozalloc_h
10
10
11
/*
11
/*
12
 * https://bugzilla.mozilla.org/show_bug.cgi?id=427099
12
 * https://bugzilla.mozilla.org/show_bug.cgi?id=427099
13
 */
13
 */
14
14
15
#include <stdlib.h>
16
#include <string.h>
17
#if defined(__cplusplus)
15
#if defined(__cplusplus)
18
#  include <new>
16
#  include <new>
17
// Since libstdc++ 6, including the C headers (e.g. stdlib.h) instead of the
18
// corresponding C++ header (e.g. cstdlib) can cause confusion in C++ code
19
// using things defined there. Specifically, with stdlib.h, the use of abs()
20
// in gfx/graphite2/src/inc/UtfCodec.h somehow ends up picking the wrong abs()
21
#  include <cstdlib>
22
#  include <cstring>
23
#else
24
#  include <stdlib.h>
25
#  include <string.h>
19
#endif
26
#endif
20
27
21
#if defined(__cplusplus)
28
#if defined(__cplusplus)
22
#include "mozilla/fallible.h"
29
#include "mozilla/fallible.h"
23
#include "mozilla/TemplateLib.h"
30
#include "mozilla/TemplateLib.h"
24
#endif
31
#endif
25
#include "mozilla/Attributes.h"
32
#include "mozilla/Attributes.h"
26
#include "mozilla/Types.h"
33
#include "mozilla/Types.h"

Return to bug 212431