]>
git.saurik.com Git - apple/libdispatch.git/blob - os/linux_base.h
2 * This source file is part of the Swift.org open source project
4 * Copyright (c) 2015 Apple Inc. and the Swift project authors
6 * Licensed under Apache License v2.0 with Runtime Library Exception
8 * See http://swift.org/LICENSE.txt for license information
9 * See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
13 #ifndef __OS_LINUX_BASE__
14 #define __OS_LINUX_BASE__
16 #include <sys/param.h>
19 #include <sys/cdefs.h>
23 #define API_AVAILABLE(...)
25 #ifndef API_DEPRECATED
26 #define API_DEPRECATED(...)
28 #ifndef API_UNAVAILABLE
29 #define API_UNAVAILABLE(...)
31 #ifndef API_DEPRECATED_WITH_REPLACEMENT
32 #define API_DEPRECATED_WITH_REPLACEMENT(...)
36 #define OS_EXPECT(x, v) __builtin_expect((x), (v))
37 #define OS_UNUSED __attribute__((__unused__))
39 #define OS_EXPECT(x, v) (x)
44 #define os_likely(x) OS_EXPECT(!!(x), 1)
47 #define os_unlikely(x) OS_EXPECT(!!(x), 0)
50 #if __has_feature(assume_nonnull)
51 #define OS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
52 #define OS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
54 #define OS_ASSUME_NONNULL_BEGIN
55 #define OS_ASSUME_NONNULL_END
58 #if __has_builtin(__builtin_assume)
59 #define OS_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
61 #define OS_COMPILER_CAN_ASSUME(expr) ((void)(expr))
64 #if __has_feature(attribute_availability_swift)
65 // equivalent to __SWIFT_UNAVAILABLE from Availability.h
66 #define OS_SWIFT_UNAVAILABLE(_msg) \
67 __attribute__((__availability__(swift, unavailable, message=_msg)))
69 #define OS_SWIFT_UNAVAILABLE(_msg)
72 #if __has_attribute(swift_private)
73 # define OS_REFINED_FOR_SWIFT __attribute__((__swift_private__))
75 # define OS_REFINED_FOR_SWIFT
78 #if __has_attribute(swift_name)
79 # define OS_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
81 # define OS_SWIFT_NAME(_name)
84 #define __OS_STRINGIFY(s) #s
85 #define OS_STRINGIFY(s) __OS_STRINGIFY(s)
86 #define __OS_CONCAT(x, y) x ## y
87 #define OS_CONCAT(x, y) __OS_CONCAT(x, y)
89 #if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
90 #define OS_ENUM(_name, _type, ...) \
91 typedef enum : _type { __VA_ARGS__ } _name##_t
93 #define OS_ENUM(_name, _type, ...) \
94 enum { __VA_ARGS__ }; typedef _type _name##_t
98 * Stub out misc linking and compilation attributes
106 #ifdef OS_WARN_RESULT_NEEDS_RELEASE
107 #undef OS_WARN_RESULT_NEEDS_RELEASE
110 #ifdef OS_WARN_RESULT
111 #undef OS_WARN_RESULT
113 #define OS_WARN_RESULT
120 #endif /* __OS_LINUX_BASE__ */