master
 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 <TargetConditionals.h>
22#include <sys/cdefs.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 *__single _Block_copy(const void *__single aBlock);
32
33// Lose the reference, and if heap based and last reference, recover the memory
34BLOCK_EXPORT void _Block_release(const void *__single aBlock);
35
36// Used by the compiler. Do not call this function yourself.
37BLOCK_EXPORT void _Block_object_assign(void *, const void *, const int);
38
39// Used by the compiler. Do not call this function yourself.
40BLOCK_EXPORT void _Block_object_dispose(const void *, const int);
41
42// Used by the compiler. Do not use these variables yourself.
43BLOCK_EXPORT void * _NSConcreteGlobalBlock[32];
44BLOCK_EXPORT void * _NSConcreteStackBlock[32];
45
46#if __cplusplus
47}
48#endif
49
50// Type correct macros
51
52#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy(__unsafe_forge_single(const void *, (const void *)(__VA_ARGS__))))
53#define Block_release(...) _Block_release(__unsafe_forge_single(const void *, (const void *)(__VA_ARGS__)))
54
55
56#endif