]>
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__
17 #include <sys/param.h>
20 #define OS_EXPECT(x, v) __builtin_expect((x), (v))
22 #define OS_EXPECT(x, v) (x)
26 #define os_likely(x) OS_EXPECT(!!(x), 1)
29 #define os_unlikely(x) OS_EXPECT(!!(x), 0)
32 #if __has_feature(assume_nonnull)
33 #define OS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
34 #define OS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
36 #define OS_ASSUME_NONNULL_BEGIN
37 #define OS_ASSUME_NONNULL_END
40 #if __has_builtin(__builtin_assume)
41 #define OS_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
43 #define OS_COMPILER_CAN_ASSUME(expr) ((void)(expr))
46 #if __has_feature(attribute_availability_swift)
47 // equivalent to __SWIFT_UNAVAILABLE from Availability.h
48 #define OS_SWIFT_UNAVAILABLE(_msg) \
49 __attribute__((__availability__(swift, unavailable, message=_msg)))
51 #define OS_SWIFT_UNAVAILABLE(_msg)
54 #if __has_attribute(swift_private)
55 # define OS_REFINED_FOR_SWIFT __attribute__((__swift_private__))
57 # define OS_REFINED_FOR_SWIFT
60 #if __has_attribute(swift_name)
61 # define OS_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
63 # define OS_SWIFT_NAME(_name)
66 #define __OS_STRINGIFY(s) #s
67 #define OS_STRINGIFY(s) __OS_STRINGIFY(s)
68 #define __OS_CONCAT(x, y) x ## y
69 #define OS_CONCAT(x, y) __OS_CONCAT(x, y)
72 * Stub out misc linking and compilation attributes
80 #ifdef OS_WARN_RESULT_NEEDS_RELEASE
81 #undef OS_WARN_RESULT_NEEDS_RELEASE
87 #define OS_WARN_RESULT
94 #endif /* __OS_LINUX_BASE__ */