|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See http://swift.org/LICENSE.txt for license information |
| 9 | +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +@_exported import Dispatch |
| 14 | + |
| 15 | +/// The type of blocks submitted to dispatch queues, which take no arguments |
| 16 | +/// and have no return value. |
| 17 | +/// |
| 18 | +/// The dispatch_block_t typealias is different from usual closures in that it |
| 19 | +/// uses @convention(block). This is to avoid unnecessary bridging between |
| 20 | +/// C blocks and Swift closures, which interferes with Grand Central Dispatch |
| 21 | +/// APIs that depend on the referential identity of a block. |
| 22 | +public typealias dispatch_block_t = @convention(block) () -> Void |
| 23 | + |
| 24 | +//===----------------------------------------------------------------------===// |
| 25 | +// Macros |
| 26 | +// FIXME: rdar://16851050 update API so these import better |
| 27 | +//===----------------------------------------------------------------------===// |
| 28 | + |
| 29 | +// dispatch/io.h |
| 30 | +public var DISPATCH_IO_STREAM: dispatch_io_type_t { |
| 31 | + return 0 |
| 32 | +} |
| 33 | +public var DISPATCH_IO_RANDOM: dispatch_io_type_t { |
| 34 | + return 1 |
| 35 | +} |
| 36 | + |
| 37 | +public var DISPATCH_IO_STOP: dispatch_io_close_flags_t { |
| 38 | + return 1 |
| 39 | +} |
| 40 | +public var DISPATCH_IO_STRICT_INTERVAL: dispatch_io_interval_flags_t { |
| 41 | + return 1 |
| 42 | +} |
| 43 | + |
| 44 | +public var DISPATCH_QUEUE_SERIAL: dispatch_queue_attr_t { |
| 45 | + return nil |
| 46 | +} |
| 47 | +public var DISPATCH_CURRENT_QUEUE_LABEL: dispatch_queue_t { |
| 48 | + return nil |
| 49 | +} |
| 50 | +public var DISPATCH_TARGET_QUEUE_DEFAULT: dispatch_queue_t { |
| 51 | + return nil |
| 52 | +} |
| 53 | +public var DISPATCH_QUEUE_PRIORITY_HIGH: dispatch_queue_priority_t { |
| 54 | + return 2 |
| 55 | +} |
| 56 | +public var DISPATCH_QUEUE_PRIORITY_DEFAULT: dispatch_queue_priority_t { |
| 57 | + return 0 |
| 58 | +} |
| 59 | +public var DISPATCH_QUEUE_PRIORITY_LOW: dispatch_queue_priority_t { |
| 60 | + return -2 |
| 61 | +} |
| 62 | +public var DISPATCH_QUEUE_PRIORITY_BACKGROUND: dispatch_queue_priority_t { |
| 63 | + return -32768 |
| 64 | +} |
| 65 | + |
| 66 | +/* |
| 67 | +FIXME: LINUX_PORT: qos_class_t not being imported |
| 68 | +@warn_unused_result |
| 69 | +public func dispatch_get_global_queue(identifier: qos_class_t, |
| 70 | + _ flags: UInt) -> dispatch_queue_t { |
| 71 | + return dispatch_get_global_queue(Int(identifier.rawValue), flags) |
| 72 | +} |
| 73 | +*/ |
| 74 | + |
| 75 | +public var DISPATCH_QUEUE_CONCURRENT: dispatch_queue_attr_t { |
| 76 | + return _swift_dispatch_queue_concurrent() |
| 77 | +} |
| 78 | + |
| 79 | +@warn_unused_result |
| 80 | +@_silgen_name("_swift_dispatch_queue_concurrent") |
| 81 | +internal func _swift_dispatch_queue_concurrent() -> dispatch_queue_attr_t |
| 82 | + |
| 83 | +// dispatch/data.h |
| 84 | +public var dispatch_data_empty: dispatch_data_t { |
| 85 | + return _swift_dispatch_data_empty() |
| 86 | +} |
| 87 | + |
| 88 | +@warn_unused_result |
| 89 | +@_silgen_name("_swift_dispatch_data_empty") |
| 90 | +internal func _swift_dispatch_data_empty() -> dispatch_data_t |
| 91 | + |
| 92 | +// dispatch/source.h |
| 93 | +// FIXME: DISPATCH_SOURCE_TYPE_* |
| 94 | +public var DISPATCH_PROC_EXIT: dispatch_source_proc_flags_t { |
| 95 | + return 0x80000000 |
| 96 | +} |
| 97 | +public var DISPATCH_PROC_FORK: dispatch_source_proc_flags_t { return 0x40000000 } |
| 98 | +public var DISPATCH_PROC_EXEC: dispatch_source_proc_flags_t { return 0x20000000 } |
| 99 | +public var DISPATCH_PROC_SIGNAL: dispatch_source_proc_flags_t { return 0x08000000 } |
| 100 | +public var DISPATCH_VNODE_DELETE: dispatch_source_vnode_flags_t { return 0x1 } |
| 101 | +public var DISPATCH_VNODE_WRITE: dispatch_source_vnode_flags_t { return 0x2 } |
| 102 | +public var DISPATCH_VNODE_EXTEND: dispatch_source_vnode_flags_t { return 0x4 } |
| 103 | +public var DISPATCH_VNODE_ATTRIB: dispatch_source_vnode_flags_t { return 0x8 } |
| 104 | +public var DISPATCH_VNODE_LINK: dispatch_source_vnode_flags_t { return 0x10 } |
| 105 | +public var DISPATCH_VNODE_RENAME: dispatch_source_vnode_flags_t { return 0x20 } |
| 106 | +public var DISPATCH_VNODE_REVOKE: dispatch_source_vnode_flags_t { return 0x40 } |
| 107 | +public var DISPATCH_TIMER_STRICT: dispatch_source_timer_flags_t { return 1 } |
| 108 | + |
| 109 | +public var DISPATCH_SOURCE_TYPE_DATA_ADD: dispatch_source_type_t { |
| 110 | + return _swift_dispatch_source_type_data_add() |
| 111 | +} |
| 112 | +public var DISPATCH_SOURCE_TYPE_DATA_OR: dispatch_source_type_t { |
| 113 | + return _swift_dispatch_source_type_data_or() |
| 114 | +} |
| 115 | +public var DISPATCH_SOURCE_TYPE_READ: dispatch_source_type_t { |
| 116 | + return _swift_dispatch_source_type_read() |
| 117 | +} |
| 118 | +public var DISPATCH_SOURCE_TYPE_PROC: dispatch_source_type_t { |
| 119 | + return _swift_dispatch_source_type_proc() |
| 120 | +} |
| 121 | +public var DISPATCH_SOURCE_TYPE_SIGNAL: dispatch_source_type_t { |
| 122 | + return _swift_dispatch_source_type_signal() |
| 123 | +} |
| 124 | +public var DISPATCH_SOURCE_TYPE_TIMER: dispatch_source_type_t { |
| 125 | + return _swift_dispatch_source_type_timer() |
| 126 | +} |
| 127 | +public var DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_type_t { |
| 128 | + return _swift_dispatch_source_type_vnode() |
| 129 | +} |
| 130 | +public var DISPATCH_SOURCE_TYPE_WRITE: dispatch_source_type_t { |
| 131 | + return _swift_dispatch_source_type_write() |
| 132 | +} |
| 133 | + |
| 134 | +@warn_unused_result |
| 135 | +@_silgen_name("_swift_dispatch_source_type_DATA_ADD") |
| 136 | +internal func _swift_dispatch_source_type_data_add() -> dispatch_source_type_t |
| 137 | + |
| 138 | +@warn_unused_result |
| 139 | +@_silgen_name("_swift_dispatch_source_type_DATA_OR") |
| 140 | +internal func _swift_dispatch_source_type_data_or() -> dispatch_source_type_t |
| 141 | + |
| 142 | +@warn_unused_result |
| 143 | +@_silgen_name("_swift_dispatch_source_type_PROC") |
| 144 | +internal func _swift_dispatch_source_type_proc() -> dispatch_source_type_t |
| 145 | + |
| 146 | +@warn_unused_result |
| 147 | +@_silgen_name("_swift_dispatch_source_type_READ") |
| 148 | +internal func _swift_dispatch_source_type_read() -> dispatch_source_type_t |
| 149 | + |
| 150 | +@warn_unused_result |
| 151 | +@_silgen_name("_swift_dispatch_source_type_SIGNAL") |
| 152 | +internal func _swift_dispatch_source_type_signal() -> dispatch_source_type_t |
| 153 | + |
| 154 | +@warn_unused_result |
| 155 | +@_silgen_name("_swift_dispatch_source_type_TIMER") |
| 156 | +internal func _swift_dispatch_source_type_timer() -> dispatch_source_type_t |
| 157 | + |
| 158 | +@warn_unused_result |
| 159 | +@_silgen_name("_swift_dispatch_source_type_VNODE") |
| 160 | +internal func _swift_dispatch_source_type_vnode() -> dispatch_source_type_t |
| 161 | + |
| 162 | +@warn_unused_result |
| 163 | +@_silgen_name("_swift_dispatch_source_type_WRITE") |
| 164 | +internal func _swift_dispatch_source_type_write() -> dispatch_source_type_t |
| 165 | + |
| 166 | +// dispatch/time.h |
| 167 | +// DISPATCH_TIME_NOW: ok |
| 168 | +// DISPATCH_TIME_FOREVER: ok |
0 commit comments