]>
git.saurik.com Git - apple/libdispatch.git/blob - dispatch/base.h
2 * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
4 * @APPLE_APACHE_LICENSE_HEADER_START@
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @APPLE_APACHE_LICENSE_HEADER_END@
21 #ifndef __DISPATCH_BASE__
22 #define __DISPATCH_BASE__
24 #ifndef __DISPATCH_INDIRECT__
25 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
30 * Dispatch objects are NOT C++ objects. Nevertheless, we can at least keep C++
31 * aware of type compatibility.
33 typedef struct dispatch_object_s
{
37 dispatch_object_s(const dispatch_object_s
&);
38 void operator=(const dispatch_object_s
&);
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 struct dispatch_data_s
*_ddata
;
51 struct dispatch_io_s
*_dchannel
;
52 struct dispatch_operation_s
*_doperation
;
53 struct dispatch_disk_s
*_ddisk
;
54 } dispatch_object_t
__attribute__((transparent_union
));
57 typedef void (*dispatch_function_t
)(void *);
60 #define DISPATCH_DECL(name) \
61 typedef struct name##_s : public dispatch_object_s {} *name##_t
64 #define DISPATCH_DECL(name) typedef struct name##_s *name##_t
68 #define DISPATCH_NORETURN __attribute__((__noreturn__))
69 #define DISPATCH_NOTHROW __attribute__((__nothrow__))
70 #define DISPATCH_NONNULL1 __attribute__((__nonnull__(1)))
71 #define DISPATCH_NONNULL2 __attribute__((__nonnull__(2)))
72 #define DISPATCH_NONNULL3 __attribute__((__nonnull__(3)))
73 #define DISPATCH_NONNULL4 __attribute__((__nonnull__(4)))
74 #define DISPATCH_NONNULL5 __attribute__((__nonnull__(5)))
75 #define DISPATCH_NONNULL6 __attribute__((__nonnull__(6)))
76 #define DISPATCH_NONNULL7 __attribute__((__nonnull__(7)))
77 #if __clang__ && __clang_major__ < 3
78 // rdar://problem/6857843
79 #define DISPATCH_NONNULL_ALL
81 #define DISPATCH_NONNULL_ALL __attribute__((__nonnull__))
83 #define DISPATCH_SENTINEL __attribute__((__sentinel__))
84 #define DISPATCH_PURE __attribute__((__pure__))
85 #define DISPATCH_CONST __attribute__((__const__))
86 #define DISPATCH_WARN_RESULT __attribute__((__warn_unused_result__))
87 #define DISPATCH_MALLOC __attribute__((__malloc__))
88 #define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__))
91 #define DISPATCH_NORETURN
93 #define DISPATCH_NOTHROW
95 #define DISPATCH_NONNULL1
97 #define DISPATCH_NONNULL2
99 #define DISPATCH_NONNULL3
101 #define DISPATCH_NONNULL4
103 #define DISPATCH_NONNULL5
105 #define DISPATCH_NONNULL6
107 #define DISPATCH_NONNULL7
109 #define DISPATCH_NONNULL_ALL
111 #define DISPATCH_SENTINEL
113 #define DISPATCH_PURE
115 #define DISPATCH_CONST
117 #define DISPATCH_WARN_RESULT
119 #define DISPATCH_MALLOC
121 #define DISPATCH_ALWAYS_INLINE
125 #define DISPATCH_EXPORT extern __attribute__((visibility("default")))
127 #define DISPATCH_EXPORT extern
131 #define DISPATCH_INLINE static __inline__
133 #define DISPATCH_INLINE static inline
137 #define DISPATCH_EXPECT(x, v) __builtin_expect((x), (v))
139 #define DISPATCH_EXPECT(x, v) (x)