1/*
2 *  Block.h
3 *
4 * Copyright (c) 2008-2010 Apple Inc. All rights reserved.
5 *
6 * @APPLE_LLVM_LICENSE_HEADER@
7 *
8 */
9
10#ifndef _Block_H_
11#define _Block_H_
12
13#if !defined(BLOCK_EXPORT)
14#   if defined(__cplusplus)
15#       define BLOCK_EXPORT extern "C"
16#   else
17#       define BLOCK_EXPORT extern
18#   endif
19#endif
20
21#include <Availability.h>
22#include <TargetConditionals.h>
23
24#if __cplusplus
25extern "C" {
26#endif
27
28// Create a heap based copy of a Block or simply add a reference to an existing one.
29// This must be paired with Block_release to recover memory, even when running
30// under Objective-C Garbage Collection.
31BLOCK_EXPORT void *_Block_copy(const void *aBlock)
32    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
33
34// Lose the reference, and if heap based and last reference, recover the memory
35BLOCK_EXPORT void _Block_release(const void *aBlock)
36    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
37
38
39// Used by the compiler. Do not call this function yourself.
40BLOCK_EXPORT void _Block_object_assign(void *, const void *, const int)
41    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
42
43// Used by the compiler. Do not call this function yourself.
44BLOCK_EXPORT void _Block_object_dispose(const void *, const int)
45    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
46
47// Used by the compiler. Do not use these variables yourself.
48BLOCK_EXPORT void * _NSConcreteGlobalBlock[32]
49    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
50BLOCK_EXPORT void * _NSConcreteStackBlock[32]
51    __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2);
52
53
54#if __cplusplus
55}
56#endif
57
58// Type correct macros
59
60#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
61#define Block_release(...) _Block_release((const void *)(__VA_ARGS__))
62
63
64#endif
65