]> git.saurik.com Git - apple/libdispatch.git/blame - dispatch/base.h
libdispatch-228.23.tar.gz
[apple/libdispatch.git] / dispatch / base.h
CommitLineData
0ab74447 1/*
e85f4437 2 * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
0ab74447
A
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
e85f4437 5 *
0ab74447
A
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
e85f4437 9 *
0ab74447 10 * http://www.apache.org/licenses/LICENSE-2.0
e85f4437 11 *
0ab74447
A
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.
e85f4437 17 *
0ab74447
A
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
e85f4437 28#if __GNUC__
0ab74447
A
29#define DISPATCH_NORETURN __attribute__((__noreturn__))
30#define DISPATCH_NOTHROW __attribute__((__nothrow__))
31#define DISPATCH_NONNULL1 __attribute__((__nonnull__(1)))
32#define DISPATCH_NONNULL2 __attribute__((__nonnull__(2)))
33#define DISPATCH_NONNULL3 __attribute__((__nonnull__(3)))
34#define DISPATCH_NONNULL4 __attribute__((__nonnull__(4)))
35#define DISPATCH_NONNULL5 __attribute__((__nonnull__(5)))
36#define DISPATCH_NONNULL6 __attribute__((__nonnull__(6)))
37#define DISPATCH_NONNULL7 __attribute__((__nonnull__(7)))
e85f4437 38#if __clang__ && __clang_major__ < 3
0ab74447
A
39// rdar://problem/6857843
40#define DISPATCH_NONNULL_ALL
41#else
42#define DISPATCH_NONNULL_ALL __attribute__((__nonnull__))
43#endif
44#define DISPATCH_SENTINEL __attribute__((__sentinel__))
45#define DISPATCH_PURE __attribute__((__pure__))
e85f4437 46#define DISPATCH_CONST __attribute__((__const__))
0ab74447
A
47#define DISPATCH_WARN_RESULT __attribute__((__warn_unused_result__))
48#define DISPATCH_MALLOC __attribute__((__malloc__))
e85f4437 49#define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__))
0ab74447
A
50#else
51/*! @parseOnly */
52#define DISPATCH_NORETURN
53/*! @parseOnly */
54#define DISPATCH_NOTHROW
55/*! @parseOnly */
56#define DISPATCH_NONNULL1
57/*! @parseOnly */
58#define DISPATCH_NONNULL2
59/*! @parseOnly */
60#define DISPATCH_NONNULL3
61/*! @parseOnly */
62#define DISPATCH_NONNULL4
63/*! @parseOnly */
64#define DISPATCH_NONNULL5
65/*! @parseOnly */
66#define DISPATCH_NONNULL6
67/*! @parseOnly */
68#define DISPATCH_NONNULL7
69/*! @parseOnly */
70#define DISPATCH_NONNULL_ALL
71/*! @parseOnly */
72#define DISPATCH_SENTINEL
73/*! @parseOnly */
74#define DISPATCH_PURE
75/*! @parseOnly */
e85f4437
A
76#define DISPATCH_CONST
77/*! @parseOnly */
0ab74447
A
78#define DISPATCH_WARN_RESULT
79/*! @parseOnly */
80#define DISPATCH_MALLOC
e85f4437
A
81/*! @parseOnly */
82#define DISPATCH_ALWAYS_INLINE
83#endif
84
85#if __GNUC__
86#define DISPATCH_EXPORT extern __attribute__((visibility("default")))
87#else
88#define DISPATCH_EXPORT extern
89#endif
90
91#if __GNUC__
92#define DISPATCH_INLINE static __inline__
93#else
94#define DISPATCH_INLINE static inline
95#endif
96
97#if __GNUC__
98#define DISPATCH_EXPECT(x, v) __builtin_expect((x), (v))
99#else
100#define DISPATCH_EXPECT(x, v) (x)
0ab74447
A
101#endif
102
c093abd6
A
103typedef void (*dispatch_function_t)(void *);
104
0ab74447 105#endif