|
| 1 | +//===--- Setup.cpp - Load-time setup code ---------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2017 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 | +#include "swift/Runtime/Metadata.h" |
| 14 | + |
| 15 | +// Helper macros for figuring out the mangled name of a context descriptor. |
| 16 | +#define DESCRIPTOR_MANGLING_SUFFIX_Structure Mn |
| 17 | +#define DESCRIPTOR_MANGLING_SUFFIX_Class Mn |
| 18 | +#define DESCRIPTOR_MANGLING_SUFFIX_Enum Mn |
| 19 | +#define DESCRIPTOR_MANGLING_SUFFIX_Protocol Mp |
| 20 | + |
| 21 | +#define DESCRIPTOR_MANGLING_SUFFIX_(X) X |
| 22 | +#define DESCRIPTOR_MANGLING_SUFFIX(KIND) \ |
| 23 | + DESCRIPTOR_MANGLING_SUFFIX_(DESCRIPTOR_MANGLING_SUFFIX_##KIND) |
| 24 | + |
| 25 | +#define DESCRIPTOR_MANGLING_(CHAR, SUFFIX) $sSc##CHAR##SUFFIX |
| 26 | +#define DESCRIPTOR_MANGLING(CHAR, SUFFIX) DESCRIPTOR_MANGLING_(CHAR, SUFFIX) |
| 27 | + |
| 28 | +// Declare context descriptors for all of the concurrency descriptors with |
| 29 | +// standard manglings. |
| 30 | +#define STANDARD_TYPE(KIND, MANGLING, TYPENAME) |
| 31 | +#define STANDARD_TYPE_CONCURRENCY(KIND, MANGLING, TYPENAME) \ |
| 32 | + extern "C" const swift::ContextDescriptor DESCRIPTOR_MANGLING( \ |
| 33 | + MANGLING, DESCRIPTOR_MANGLING_SUFFIX(KIND)); |
| 34 | +#include "swift/Demangling/StandardTypesMangling.def" |
| 35 | + |
| 36 | +// Register our type descriptors with standard manglings when the concurrency |
| 37 | +// runtime is loaded. This allows the runtime to quickly resolve those standard |
| 38 | +// manglings. |
| 39 | +__attribute__((constructor)) static void setupStandardConcurrencyDescriptors() { |
| 40 | + static const swift::ConcurrencyStandardTypeDescriptors descriptors = { |
| 41 | +#define STANDARD_TYPE(KIND, MANGLING, TYPENAME) |
| 42 | +#define STANDARD_TYPE_CONCURRENCY(KIND, MANGLING, TYPENAME) \ |
| 43 | + &DESCRIPTOR_MANGLING(MANGLING, DESCRIPTOR_MANGLING_SUFFIX(KIND)), |
| 44 | +#include "swift/Demangling/StandardTypesMangling.def" |
| 45 | + }; |
| 46 | + _swift_registerConcurrencyStandardTypeDescriptors(&descriptors); |
| 47 | +} |
0 commit comments