Tizen 2.1 base
[platform/upstream/gcd.git] / dispatch-1.0 / dispatch / base.h
1 /*
2  * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
3  *
4  * @APPLE_APACHE_LICENSE_HEADER_START@
5  * 
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  * 
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  * 
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * 
18  * @APPLE_APACHE_LICENSE_HEADER_END@
19  */
20
21 #ifndef __DISPATCH_BASE__
22 #define __DISPATCH_BASE__
23
24 #ifndef __DISPATCH_INDIRECT__
25 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
26 #endif
27
28 #ifdef __cplusplus
29 /*
30  * Dispatch objects are NOT C++ objects. Nevertheless, we can at least keep C++
31  * aware of type compatibility.
32  */
33 typedef struct dispatch_object_s {
34 private:
35         dispatch_object_s();
36         ~dispatch_object_s();
37         dispatch_object_s(const dispatch_object_s &);
38         void operator=(const dispatch_object_s &);
39 } *dispatch_object_t;
40 #else
41 typedef union {
42         struct dispatch_object_s *_do;
43         struct dispatch_continuation_s *_dc;
44         struct dispatch_queue_s *_dq;
45         struct dispatch_queue_attr_s *_dqa;
46         struct dispatch_group_s *_dg;
47         struct dispatch_source_s *_ds;
48         struct dispatch_source_attr_s *_dsa;
49         struct dispatch_semaphore_s *_dsema;
50 } dispatch_object_t __attribute__((transparent_union));
51 #endif
52
53 typedef void (*dispatch_function_t)(void *);
54
55 #ifdef __cplusplus
56 #define DISPATCH_DECL(name) typedef struct name##_s : public dispatch_object_s {} *name##_t
57 #else
58 /*! @parseOnly */
59 #define DISPATCH_DECL(name) typedef struct name##_s *name##_t
60 #endif
61
62 #ifdef __GNUC__
63 #define DISPATCH_NORETURN __attribute__((__noreturn__))
64 #define DISPATCH_NOTHROW __attribute__((__nothrow__))
65 #define DISPATCH_NONNULL1 __attribute__((__nonnull__(1)))
66 #define DISPATCH_NONNULL2 __attribute__((__nonnull__(2)))
67 #define DISPATCH_NONNULL3 __attribute__((__nonnull__(3)))
68 #define DISPATCH_NONNULL4 __attribute__((__nonnull__(4)))
69 #define DISPATCH_NONNULL5 __attribute__((__nonnull__(5)))
70 #define DISPATCH_NONNULL6 __attribute__((__nonnull__(6)))
71 #define DISPATCH_NONNULL7 __attribute__((__nonnull__(7)))
72 #if __clang__
73 // rdar://problem/6857843
74 #define DISPATCH_NONNULL_ALL
75 #else
76 #define DISPATCH_NONNULL_ALL __attribute__((__nonnull__))
77 #endif
78 #define DISPATCH_SENTINEL __attribute__((__sentinel__))
79 #define DISPATCH_PURE __attribute__((__pure__))
80 #define DISPATCH_WARN_RESULT __attribute__((__warn_unused_result__))
81 #define DISPATCH_MALLOC __attribute__((__malloc__))
82 #define DISPATCH_FORMAT(...) __attribute__((__format__(__VA_ARGS__)))
83 #else
84 /*! @parseOnly */
85 #define DISPATCH_NORETURN
86 /*! @parseOnly */
87 #define DISPATCH_NOTHROW
88 /*! @parseOnly */
89 #define DISPATCH_NONNULL1
90 /*! @parseOnly */
91 #define DISPATCH_NONNULL2
92 /*! @parseOnly */
93 #define DISPATCH_NONNULL3
94 /*! @parseOnly */
95 #define DISPATCH_NONNULL4
96 /*! @parseOnly */
97 #define DISPATCH_NONNULL5
98 /*! @parseOnly */
99 #define DISPATCH_NONNULL6
100 /*! @parseOnly */
101 #define DISPATCH_NONNULL7
102 /*! @parseOnly */
103 #define DISPATCH_NONNULL_ALL
104 /*! @parseOnly */
105 #define DISPATCH_SENTINEL
106 /*! @parseOnly */
107 #define DISPATCH_PURE
108 /*! @parseOnly */
109 #define DISPATCH_WARN_RESULT
110 /*! @parseOnly */
111 #define DISPATCH_MALLOC
112 /*! @parseOnly */
113 #define DISPATCH_FORMAT(...)
114 #endif
115
116 #if __GNUC__
117 #define DISPATCH_EXPORT extern __attribute__((visibility("default")))
118 #else
119 #define DISPATCH_EXPORT extern
120 #endif
121
122 #endif