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

Side by Side Diff: chrome/browser/mac/closure_blocks_leopard_compat.h

Issue 7582032: Allow use of ^blocks, even with the 10.5 SDK, and even with a 10.5 runtime (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | « no previous file | chrome/browser/mac/closure_blocks_leopard_compat.S » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_MAC_CLOSURE_BLOCKS_LEOPARD_COMPAT_H_
6 #define CHROME_BROWSER_MAC_CLOSURE_BLOCKS_LEOPARD_COMPAT_H_
7 #pragma once
8
9 // libclosure (blocks) compatibilty for Mac OS X 10.5 (Leopard)
10 //
11 // Background material:
12 // http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Blocks
13 // http://opensource.apple.com/source/libclosure/libclosure-38/
14 //
15 // Leopard doesn't support blocks. Chrome supports Leopard. Chrome needs to use
16 // blocks.
17 //
18 // In any file where you use blocks (any time you type ^{...}), you must
19 // #include this file to ensure that the runtime symbols referenced by code
20 // emitted by the compiler are marked for weak-import. This means that if
21 // these symbols are not present at runtime, the program will still load, but
22 // their values will be NULL.
23 //
24 // In any target (in the GYP sense) where you use blocks, you must also depend
25 // on the closure_blocks_leopard_compat target to ensure that these symbols
26 // will be available at link time, even when the 10.5 SDK is in use. This
27 // This allows the continued use of the 10.5 SDK, which does not contain these
28 // symbols.
29 //
30 // This does not relieve you of the responsibility to not use blocks on
31 // Leopard. Because runtime support for Blocks still isn't present on that
32 // operating system, the weak-imported symbols will have value 0 and attempts
33 // to do anything meaningful with them will fail or crash. You must take care
34 // not to enter any codepath that uses blocks on Leopard. The base::mac::IsOS*
35 // family may be helpful.
36 //
37 // Although this scheme allows the use of the 10.5 SDK and 10.5 runtime in an
38 // application that uses blocks, it is still necessary to use a compiler that
39 // supports blocks. GCC 4.2 as shipped with Xcode 3.2 for Mac OS X 10.6
40 // qualifies, as do sufficiently recent versions of clang. GCC 4.2 as shipped
41 // with Xcode 3.1 for Mac OS X 10.5 does not qualify.
42
43 // _NSConcreteGlobalBlock and _NSConcreteStackBlock are a private
44 // implementation details of libclosure defined in
45 // libclosure/libclosure-38/Block_private.h, but they're exposed from
46 // libSystem as public symbols, and the block-enabled compiler will emit code
47 // that references these symbols. Because the symbols aren't present in 10.5's
48 // libSystem, they must be declared as weak imports in any file that uses
49 // blocks. Any block-using file must #include this header to guarantee that
50 // the symbols will show up in linked output as weak imports when compiling
51 // for a 10.5 deployment target. Because the symbols are always present in
52 // 10.6 and higher, they do not need to be a weak imports when the deployment
53 // target is at least 10.6.
54 //
55 // Both GCC and clang emit references to these symbols, providing implicit
56 // declarations as needed, but respecting any user declaration when present.
57 // See gcc-5666.3/gcc/c-parser.c build_block_struct_initlist,
58 // gcc-5666.3/gcc/cp/parser.c build_block_struct_initlist, and
59 // clang-2.9/lib/CodeGen/CodeGenModule.cpp
60 // CodeGenModule::getNSConcreteGlobalBlock() and
61 // CodeGenModule::getNSConcreteStackBlock().
62
63 #include <AvailabilityMacros.h>
64
65 extern "C" {
66
67 #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_5 // DT <= 10.5
68 #define MAYBE_WEAK_IMPORT __attribute__((weak_import))
69 #else // DT > 10.5
70 #define MAYBE_WEAK_IMPORT
71 #endif // DT <= 10.5
72
73 MAYBE_WEAK_IMPORT extern void* _NSConcreteGlobalBlock[32];
74 MAYBE_WEAK_IMPORT extern void* _NSConcreteStackBlock[32];
75
76 #undef MAYBE_WEAK_IMPORT
77
78 } // extern "C"
79
80 #endif // CHROME_BROWSER_MAC_CLOSURE_BLOCKS_LEOPARD_COMPAT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/mac/closure_blocks_leopard_compat.S » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698