|
| 1 | +///===--- ExecutorChecks.cpp - Static assertions to check struct layouts ---===/// |
| 2 | +/// |
| 3 | +/// This source file is part of the Swift.org open source project |
| 4 | +/// |
| 5 | +/// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors |
| 6 | +/// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +/// |
| 8 | +/// See https:///swift.org/LICENSE.txt for license information |
| 9 | +/// See https:///swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +/// |
| 11 | +///===----------------------------------------------------------------------===/// |
| 12 | +/// |
| 13 | +/// This file is responsible for checking that the structures in ExecutorImpl.h |
| 14 | +/// are laid out exactly the same as those in the ABI headers. |
| 15 | +/// |
| 16 | +///===----------------------------------------------------------------------===/// |
| 17 | + |
| 18 | +#include "swift/Runtime/Concurrency.h" |
| 19 | + |
| 20 | +#include "swift/ABI/Executor.h" |
| 21 | +#include "swift/ABI/MetadataValues.h" |
| 22 | +#include "swift/ABI/Task.h" |
| 23 | + |
| 24 | +#include "ExecutorImpl.h" |
| 25 | + |
| 26 | +// JobFlags |
| 27 | +static_assert(sizeof(swift::JobFlags) == sizeof(SwiftJobFlags)); |
| 28 | + |
| 29 | +// JobKind |
| 30 | +static_assert(sizeof(swift::JobKind) == sizeof(SwiftJobKind)); |
| 31 | +static_assert((SwiftJobKind)swift::JobKind::Task == SwiftTaskJobKind); |
| 32 | +static_assert((SwiftJobKind)swift::JobKind::First_Reserved == SwiftFirstReservedJobKind); |
| 33 | + |
| 34 | +// JobPriority |
| 35 | +static_assert(sizeof(swift::JobPriority) == sizeof(SwiftJobPriority)); |
| 36 | +static_assert((SwiftJobPriority)swift::JobPriority::UserInteractive |
| 37 | + == SwiftUserInteractiveJobPriority); |
| 38 | +static_assert((SwiftJobPriority)swift::JobPriority::UserInteractive |
| 39 | + == SwiftUserInteractiveJobPriority); |
| 40 | +static_assert((SwiftJobPriority)swift::JobPriority::UserInitiated |
| 41 | + == SwiftUserInitiatedJobPriority); |
| 42 | +static_assert((SwiftJobPriority)swift::JobPriority::Default |
| 43 | + == SwiftDefaultJobPriority); |
| 44 | +static_assert((SwiftJobPriority)swift::JobPriority::Utility |
| 45 | + == SwiftUtilityJobPriority); |
| 46 | +static_assert((SwiftJobPriority)swift::JobPriority::Background |
| 47 | + == SwiftBackgroundJobPriority); |
| 48 | +static_assert((SwiftJobPriority)swift::JobPriority::Unspecified |
| 49 | + == SwiftUnspecifiedJobPriority); |
| 50 | + |
| 51 | +// Job (has additional fields not exposed via SwiftJob) |
| 52 | +static_assert(sizeof(swift::Job) >= sizeof(SwiftJob)); |
| 53 | +static_assert(offsetof(swift::Job, metadata) == offsetof(SwiftJob, metadata)); |
| 54 | +static_assert(offsetof(swift::Job, refCounts) == offsetof(SwiftJob, refCounts)); |
| 55 | +static_assert(offsetof(swift::Job, SchedulerPrivate) == offsetof(SwiftJob, schedulerPrivate)); |
| 56 | +static_assert(offsetof(swift::Job, SchedulerPrivate[0]) == offsetof(SwiftJob, schedulerPrivate[0])); |
| 57 | +static_assert(offsetof(swift::Job, SchedulerPrivate[1]) == offsetof(SwiftJob, schedulerPrivate[1])); |
| 58 | +static_assert(offsetof(swift::Job, Flags) == offsetof(SwiftJob, flags)); |
| 59 | + |
| 60 | +// SerialExecutorRef |
| 61 | +static_assert(sizeof(swift::SerialExecutorRef) == sizeof(SwiftExecutorRef)); |
| 62 | + |
| 63 | +// swift_clock_id |
| 64 | +static_assert((SwiftClockId)swift::swift_clock_id_continuous |
| 65 | + == SwiftContinuousClock); |
| 66 | +static_assert((SwiftClockId)swift::swift_clock_id_suspending |
| 67 | + == SwiftSuspendingClock); |
0 commit comments