From 9c8bbe68490d277cf64459b3390cf48e2a09ddf6 Mon Sep 17 00:00:00 2001 From: pfg Date: Sun, 5 Jan 2014 00:43:28 +0000 Subject: gcc: Add support for Apple's Block extension Block objects [1] are a C-level syntactic and runtime feature. They are similar to standard C functions, but in addition to executable code they may also contain variable bindings to automatic (stack) or managed (heap) memory. A block can therefore maintain a set of state (data) that it can use to impact behavior when executed. This port is based on Apple's GCC 5646 with some bugfixes from Apple GCC 5666.3. It has some small differences with the support in clang, which remains the recommended compiler. Perhaps the most notable difference is that in GCC that __block is not actually a keyword, but a macro. There will be workaround for this issue in a near future. Other issues can be consulted in the clang documentation [2] For better compatiblity with Apple's GCC and llvm-gcc some related fixes and features from Apple have been included. Support for the non-standard nested functions in GCC is now off by default. No effort was made to update the ObjC support since FreeBSD doesn't carry ObjC in the base system, but some of the code crept in and was more difficult to remove than to adjust. Reference: [1] https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html [2] http://clang.llvm.org/compatibility.html#block-variable-initialization Obtained from: Apple GCC 4.2 MFC after: 3 weeks --- contrib/gcc/c-convert.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'contrib/gcc/c-convert.c') diff --git a/contrib/gcc/c-convert.c b/contrib/gcc/c-convert.c index b2b5ea1..b13a713 100644 --- a/contrib/gcc/c-convert.c +++ b/contrib/gcc/c-convert.c @@ -104,6 +104,10 @@ convert (tree type, tree expr) return fold_convert (type, c_objc_common_truthvalue_conversion (expr)); if (code == POINTER_TYPE || code == REFERENCE_TYPE) return fold (convert_to_pointer (type, e)); + /* APPLE LOCAL begin blocks (C++ ck) */ + if (code == BLOCK_POINTER_TYPE) + return fold (convert_to_block_pointer (type, e)); + /* APPLE LOCAL end blocks (C++ ck) */ if (code == REAL_TYPE) return fold (convert_to_real (type, e)); if (code == COMPLEX_TYPE) -- cgit v1.1