]>
git.saurik.com Git - apple/libdispatch.git/blob - src/BlocksRuntime/Block.h
1 // This source file is part of the Swift.org open source project
3 // Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
4 // Licensed under Apache License v2.0 with Runtime Library Exception
6 // See http://swift.org/LICENSE.txt for license information
7 // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
14 #if !defined(BLOCK_EXPORT)
15 # if defined(__cplusplus)
16 # define BLOCK_EXPORT extern "C" __attribute__((visibility("default")))
18 # define BLOCK_EXPORT extern __attribute__((visibility("default")))
26 // Create a heap based copy of a Block or simply add a reference to an existing one.
27 // This must be paired with Block_release to recover memory, even when running
28 // under Objective-C Garbage Collection.
29 BLOCK_EXPORT
void *_Block_copy(const void *aBlock
);
31 // Lose the reference, and if heap based and last reference, recover the memory
32 BLOCK_EXPORT
void _Block_release(const void *aBlock
);
34 // Used by the compiler. Do not call this function yourself.
35 BLOCK_EXPORT
void _Block_object_assign(void *, const void *, const int);
37 // Used by the compiler. Do not call this function yourself.
38 BLOCK_EXPORT
void _Block_object_dispose(const void *, const int);
40 // Used by the compiler. Do not use these variables yourself.
41 BLOCK_EXPORT
void * _NSConcreteGlobalBlock
[32];
42 BLOCK_EXPORT
void * _NSConcreteStackBlock
[32];
48 // Type correct macros
50 #define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
51 #define Block_release(...) _Block_release((const void *)(__VA_ARGS__))