Skip to content

Commit 68c3553

Browse files
committed
Merge libdispatch-1186
Signed-off-by: Rokhini Prabhu <[email protected]>
1 parent 43a77d2 commit 68c3553

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3105
-1164
lines changed

cmake/modules/DispatchCompilerWarnings.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ else()
3838
add_compile_options(-Wsign-conversion)
3939
add_compile_options(-Wstatic-in-inline)
4040
add_compile_options(-Wsuper-class-method-mismatch)
41-
add_compile_options(-Wswitch-enum)
41+
add_compile_options(-Wswitch)
4242
add_compile_options(-Wunguarded-availability)
4343
add_compile_options(-Wunreachable-code)
4444
add_compile_options(-Wunused)

dispatch/base.h

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,35 @@
237237
#endif
238238
#endif
239239

240-
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums) || defined(_WIN32)
240+
#if __has_attribute(enum_extensibility)
241+
#define __DISPATCH_ENUM_ATTR __attribute__((__enum_extensibility__(open)))
242+
#define __DISPATCH_ENUM_ATTR_CLOSED __attribute__((__enum_extensibility__(closed)))
243+
#else
244+
#define __DISPATCH_ENUM_ATTR
245+
#define __DISPATCH_ENUM_ATTR_CLOSED
246+
#endif // __has_attribute(enum_extensibility)
247+
248+
#if __has_attribute(flag_enum)
249+
#define __DISPATCH_OPTIONS_ATTR __attribute__((__flag_enum__))
250+
#else
251+
#define __DISPATCH_OPTIONS_ATTR
252+
#endif // __has_attribute(flag_enum)
253+
254+
255+
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums) || \
256+
__has_extension(cxx_fixed_enum) || defined(_WIN32)
241257
#define DISPATCH_ENUM(name, type, ...) \
242-
typedef enum : type { __VA_ARGS__ } name##_t
258+
typedef enum : type { __VA_ARGS__ } __DISPATCH_ENUM_ATTR name##_t
259+
#define DISPATCH_OPTIONS(name, type, ...) \
260+
typedef enum : type { __VA_ARGS__ } __DISPATCH_OPTIONS_ATTR __DISPATCH_ENUM_ATTR name##_t
243261
#else
244262
#define DISPATCH_ENUM(name, type, ...) \
245-
enum { __VA_ARGS__ }; typedef type name##_t
246-
#endif
263+
enum { __VA_ARGS__ } __DISPATCH_ENUM_ATTR; typedef type name##_t
264+
#define DISPATCH_OPTIONS(name, type, ...) \
265+
enum { __VA_ARGS__ } __DISPATCH_OPTIONS_ATTR __DISPATCH_ENUM_ATTR; typedef type name##_t
266+
#endif // __has_feature(objc_fixed_enum) ...
267+
268+
247269

248270
#if __has_feature(enumerator_attributes)
249271
#define DISPATCH_ENUM_API_AVAILABLE(...) API_AVAILABLE(__VA_ARGS__)
@@ -256,12 +278,11 @@
256278
#define DISPATCH_ENUM_API_DEPRECATED_WITH_REPLACEMENT(...)
257279
#endif
258280

259-
#if defined(SWIFT_SDK_OVERLAY_DISPATCH_EPOCH) && \
260-
SWIFT_SDK_OVERLAY_DISPATCH_EPOCH >= 2
281+
#ifdef __swift__
261282
#define DISPATCH_SWIFT3_OVERLAY 1
262-
#else
283+
#else // __swift__
263284
#define DISPATCH_SWIFT3_OVERLAY 0
264-
#endif // SWIFT_SDK_OVERLAY_DISPATCH_EPOCH >= 2
285+
#endif // __swift__
265286

266287
#if __has_feature(attribute_availability_swift)
267288
#define DISPATCH_SWIFT_UNAVAILABLE(_msg) \

dispatch/block.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ __BEGIN_DECLS
100100
* for synchronous execution or when the dispatch block object is invoked
101101
* directly.
102102
*/
103-
DISPATCH_ENUM(dispatch_block_flags, unsigned long,
103+
DISPATCH_OPTIONS(dispatch_block_flags, unsigned long,
104104
DISPATCH_BLOCK_BARRIER
105105
DISPATCH_ENUM_API_AVAILABLE(macos(10.10), ios(8.0)) = 0x1,
106106
DISPATCH_BLOCK_DETACHED

dispatch/dispatch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#endif
5151
#endif
5252

53-
#define DISPATCH_API_VERSION 20180109
53+
#define DISPATCH_API_VERSION 20181008
5454

5555
#ifndef __DISPATCH_BUILDING_DISPATCH__
5656
#ifndef __DISPATCH_INDIRECT__
@@ -69,6 +69,7 @@
6969
#include <dispatch/once.h>
7070
#include <dispatch/data.h>
7171
#include <dispatch/io.h>
72+
#include <dispatch/workloop.h>
7273

7374
#undef __DISPATCH_INDIRECT__
7475
#endif /* !__DISPATCH_BUILDING_DISPATCH__ */

dispatch/object.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include <dispatch/base.h> // for HeaderDoc
2727
#endif
2828

29+
#if __has_include(<sys/qos.h>)
30+
#include <sys/qos.h>
31+
#endif
32+
2933
DISPATCH_ASSUME_NONNULL_BEGIN
3034

3135
/*!
@@ -95,6 +99,7 @@ typedef union {
9599
struct dispatch_queue_attr_s *_dqa;
96100
struct dispatch_group_s *_dg;
97101
struct dispatch_source_s *_ds;
102+
struct dispatch_channel_s *_dch;
98103
struct dispatch_mach_s *_dm;
99104
struct dispatch_mach_msg_s *_dmsg;
100105
struct dispatch_semaphore_s *_dsema;
@@ -178,6 +183,16 @@ typedef void (^dispatch_block_t)(void);
178183

179184
__BEGIN_DECLS
180185

186+
/*!
187+
* @typedef dispatch_qos_class_t
188+
* Alias for qos_class_t type.
189+
*/
190+
#if __has_include(<sys/qos.h>)
191+
typedef qos_class_t dispatch_qos_class_t;
192+
#else
193+
typedef unsigned int dispatch_qos_class_t;
194+
#endif
195+
181196
/*!
182197
* @function dispatch_retain
183198
*
@@ -374,6 +389,49 @@ DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
374389
void
375390
dispatch_resume(dispatch_object_t object);
376391

392+
/*!
393+
* @function dispatch_set_qos_class_floor
394+
*
395+
* @abstract
396+
* Sets the QOS class floor on a dispatch queue, source or workloop.
397+
*
398+
* @discussion
399+
* The QOS class of workitems submitted to this object asynchronously will be
400+
* elevated to at least the specified QOS class floor. The QOS of the workitem
401+
* will be used if higher than the floor even when the workitem has been created
402+
* without "ENFORCE" semantics.
403+
*
404+
* Setting the QOS class floor is equivalent to the QOS effects of configuring
405+
* a queue whose target queue has a QoS class set to the same value.
406+
*
407+
* @param object
408+
* A dispatch queue, workloop, or source to configure.
409+
* The object must be inactive.
410+
*
411+
* Passing another object type or an object that has been activated is undefined
412+
* and will cause the process to be terminated.
413+
*
414+
* @param qos_class
415+
* A QOS class value:
416+
* - QOS_CLASS_USER_INTERACTIVE
417+
* - QOS_CLASS_USER_INITIATED
418+
* - QOS_CLASS_DEFAULT
419+
* - QOS_CLASS_UTILITY
420+
* - QOS_CLASS_BACKGROUND
421+
* Passing any other value is undefined.
422+
*
423+
* @param relative_priority
424+
* A relative priority within the QOS class. This value is a negative
425+
* offset from the maximum supported scheduler priority for the given class.
426+
* Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
427+
* is undefined.
428+
*/
429+
API_AVAILABLE(macos(10.14), ios(12.0), tvos(12.0), watchos(5.0))
430+
DISPATCH_EXPORT DISPATCH_NOTHROW
431+
void
432+
dispatch_set_qos_class_floor(dispatch_object_t object,
433+
dispatch_qos_class_t qos_class, int relative_priority);
434+
377435
#ifdef __BLOCKS__
378436
/*!
379437
* @function dispatch_wait

0 commit comments

Comments
 (0)