Skip to content

Commit a5a4880

Browse files
committed
Remove extern "C" uses of SWIFT_RT_ENTRY_VISIBILITY
1 parent 05a50fd commit a5a4880

File tree

8 files changed

+34
-54
lines changed

8 files changed

+34
-54
lines changed

include/swift/Runtime/Enum.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ void swift_initEnumValueWitnessTableSinglePayload(ValueWitnessTable *vwtable,
5656
/// returns a value greater than or equal to zero and less than
5757
/// emptyCases.
5858
SWIFT_RT_ENTRY_VISIBILITY
59-
extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
60-
const Metadata *payload,
61-
unsigned emptyCases)
59+
int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
60+
const Metadata *payload,
61+
unsigned emptyCases)
6262
SWIFT_CC(RegisterPreservingCC);
6363

6464

@@ -75,10 +75,10 @@ extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
7575
/// than emptyCases for an empty case.
7676
/// \param emptyCases - the number of empty cases in the enum.
7777
SWIFT_RT_ENTRY_VISIBILITY
78-
extern "C" void swift_storeEnumTagSinglePayload(OpaqueValue *value,
79-
const Metadata *payload,
80-
int whichCase,
81-
unsigned emptyCases)
78+
void swift_storeEnumTagSinglePayload(OpaqueValue *value,
79+
const Metadata *payload,
80+
int whichCase,
81+
unsigned emptyCases)
8282
SWIFT_CC(RegisterPreservingCC);
8383

8484
/// \brief Initialize the value witness table for a generic, multi-payload

include/swift/Runtime/HeapObject.h

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ struct OpaqueValue;
6060
/// POSSIBILITIES: The argument order is fair game. It may be useful
6161
/// to have a variant which guarantees zero-initialized memory.
6262
SWIFT_RT_ENTRY_VISIBILITY
63-
extern "C"
6463
HeapObject *swift_allocObject(HeapMetadata const *metadata,
6564
size_t requiredSize,
6665
size_t requiredAlignmentMask)
@@ -170,15 +169,13 @@ BoxPair::Return (*_swift_allocBox)(Metadata const *type)
170169
// An "alignment mask" is just the alignment (a power of 2) minus 1.
171170

172171
SWIFT_RT_ENTRY_VISIBILITY
173-
extern "C"
174172
void *swift_slowAlloc(size_t bytes, size_t alignMask)
175173
SWIFT_CC(RegisterPreservingCC);
176174

177175

178176
// If the caller cannot promise to zero the object during destruction,
179177
// then call these corresponding APIs:
180178
SWIFT_RT_ENTRY_VISIBILITY
181-
extern "C"
182179
void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask)
183180
SWIFT_CC(RegisterPreservingCC);
184181

@@ -195,15 +192,13 @@ void swift_slowDealloc(void *ptr, size_t bytes, size_t alignMask)
195192
/// It may also prove worthwhile to have this use a custom CC
196193
/// which preserves a larger set of registers.
197194
SWIFT_RT_ENTRY_VISIBILITY
198-
extern "C"
199195
void swift_retain(HeapObject *object)
200196
SWIFT_CC(RegisterPreservingCC);
201197

202198
SWIFT_RUNTIME_EXPORT
203199
void (*SWIFT_CC(RegisterPreservingCC) _swift_retain)(HeapObject *object);
204200

205201
SWIFT_RT_ENTRY_VISIBILITY
206-
extern "C"
207202
void swift_retain_n(HeapObject *object, uint32_t n)
208203
SWIFT_CC(RegisterPreservingCC);
209204

@@ -212,15 +207,13 @@ void (*SWIFT_CC(RegisterPreservingCC) _swift_retain_n)(HeapObject *object,
212207
uint32_t n);
213208

214209
SWIFT_RT_ENTRY_VISIBILITY
215-
extern "C"
216210
void swift_nonatomic_retain(HeapObject *object)
217211
SWIFT_CC(RegisterPreservingCC);
218212

219213
SWIFT_RUNTIME_EXPORT
220214
void (*SWIFT_CC(RegisterPreservingCC) _swift_nonatomic_retain)(HeapObject *object);
221215

222216
SWIFT_RT_ENTRY_VISIBILITY
223-
extern "C"
224217
void swift_nonatomic_retain_n(HeapObject *object, uint32_t n)
225218
SWIFT_CC(RegisterPreservingCC);
226219

@@ -243,7 +236,6 @@ static inline void _swift_nonatomic_retain_inlined(HeapObject *object) {
243236
/// Atomically increments the reference count of an object, unless it has
244237
/// already been destroyed. Returns nil if the object is dead.
245238
SWIFT_RT_ENTRY_VISIBILITY
246-
extern "C"
247239
HeapObject *swift_tryRetain(HeapObject *object)
248240
SWIFT_CC(RegisterPreservingCC);
249241

@@ -266,23 +258,23 @@ bool (* SWIFT_CC(RegisterPreservingCC) _swift_isDeallocating)(HeapObject *);
266258
///
267259
/// The object reference may not be nil.
268260
SWIFT_RT_ENTRY_VISIBILITY
269-
extern "C" HeapObject *swift_tryPin(HeapObject *object)
261+
HeapObject *swift_tryPin(HeapObject *object)
270262
SWIFT_CC(RegisterPreservingCC);
271263

272264
SWIFT_RT_ENTRY_VISIBILITY
273-
extern "C" HeapObject *swift_nonatomic_tryPin(HeapObject *object)
265+
HeapObject *swift_nonatomic_tryPin(HeapObject *object)
274266
SWIFT_CC(RegisterPreservingCC);
275267

276268
/// Given that an object is pinned, atomically unpin it and decrement
277269
/// the reference count.
278270
///
279271
/// The object reference may be nil (to simplify the protocol).
280272
SWIFT_RT_ENTRY_VISIBILITY
281-
extern "C" void swift_unpin(HeapObject *object)
273+
void swift_unpin(HeapObject *object)
282274
SWIFT_CC(RegisterPreservingCC);
283275

284276
SWIFT_RT_ENTRY_VISIBILITY
285-
extern "C" void swift_nonatomic_unpin(HeapObject *object)
277+
void swift_nonatomic_unpin(HeapObject *object)
286278
SWIFT_CC(RegisterPreservingCC);
287279

288280
/// Atomically decrements the retain count of an object. If the
@@ -301,7 +293,6 @@ extern "C" void swift_nonatomic_unpin(HeapObject *object)
301293
/// - maybe a variant that can assume a non-null object
302294
/// It's unlikely that a custom CC would be beneficial here.
303295
SWIFT_RT_ENTRY_VISIBILITY
304-
extern "C"
305296
void swift_release(HeapObject *object)
306297
SWIFT_CC(RegisterPreservingCC);
307298

@@ -310,7 +301,7 @@ void (*SWIFT_CC(RegisterPreservingCC)
310301
_swift_release)(HeapObject *object);
311302

312303
SWIFT_RT_ENTRY_VISIBILITY
313-
extern "C" void swift_nonatomic_release(HeapObject *object)
304+
void swift_nonatomic_release(HeapObject *object)
314305
SWIFT_CC(RegisterPreservingCC);
315306

316307
SWIFT_RUNTIME_EXPORT
@@ -321,7 +312,6 @@ void (*SWIFT_CC(RegisterPreservingCC)
321312
/// Atomically decrements the retain count of an object n times. If the retain
322313
/// count reaches zero, the object is destroyed
323314
SWIFT_RT_ENTRY_VISIBILITY
324-
extern "C"
325315
void swift_release_n(HeapObject *object, uint32_t n)
326316
SWIFT_CC(RegisterPreservingCC);
327317

@@ -336,7 +326,6 @@ SWIFT_RUNTIME_EXPORT
336326
void swift_setDeallocating(HeapObject *object);
337327

338328
SWIFT_RT_ENTRY_VISIBILITY
339-
extern "C"
340329
void swift_nonatomic_release_n(HeapObject *object, uint32_t n)
341330
SWIFT_CC(RegisterPreservingCC);
342331

@@ -385,19 +374,19 @@ bool swift_isUniquelyReferenced_native(const struct HeapObject *);
385374
/// Is this native Swift pointer a non-null unique or pinned reference
386375
/// to an object?
387376
SWIFT_RT_ENTRY_VISIBILITY
388-
extern "C" bool swift_isUniquelyReferencedOrPinned_native(
377+
bool swift_isUniquelyReferencedOrPinned_native(
389378
const struct HeapObject *) SWIFT_CC(RegisterPreservingCC);
390379

391380
/// Is this non-null native Swift pointer a unique reference to
392381
/// an object?
393382
SWIFT_RT_ENTRY_VISIBILITY
394-
extern "C" bool swift_isUniquelyReferenced_nonNull_native(
383+
bool swift_isUniquelyReferenced_nonNull_native(
395384
const struct HeapObject *) SWIFT_CC(RegisterPreservingCC);
396385

397386
/// Does this non-null native Swift pointer refer to an object that
398387
/// is either uniquely referenced or pinned?
399388
SWIFT_RT_ENTRY_VISIBILITY
400-
extern "C" bool swift_isUniquelyReferencedOrPinned_nonNull_native(
389+
bool swift_isUniquelyReferencedOrPinned_nonNull_native(
401390
const struct HeapObject *) SWIFT_CC(RegisterPreservingCC);
402391

403392
/// Deallocate the given memory.
@@ -416,8 +405,8 @@ extern "C" bool swift_isUniquelyReferencedOrPinned_nonNull_native(
416405
/// requires the object to have been fully zeroed from offsets
417406
/// sizeof(SwiftHeapObject) to allocatedSize.
418407
SWIFT_RT_ENTRY_VISIBILITY
419-
extern "C" void swift_deallocObject(HeapObject *object, size_t allocatedSize,
420-
size_t allocatedAlignMask)
408+
void swift_deallocObject(HeapObject *object, size_t allocatedSize,
409+
size_t allocatedAlignMask)
421410
SWIFT_CC(RegisterPreservingCC);
422411

423412
/// Deallocate the given memory.
@@ -527,35 +516,35 @@ struct UnownedReference {
527516

528517
/// Increment the weak/unowned retain count.
529518
SWIFT_RT_ENTRY_VISIBILITY
530-
extern "C" void swift_unownedRetain(HeapObject *value)
519+
void swift_unownedRetain(HeapObject *value)
531520
SWIFT_CC(RegisterPreservingCC);
532521

533522
/// Decrement the weak/unowned retain count.
534523
SWIFT_RT_ENTRY_VISIBILITY
535-
extern "C" void swift_unownedRelease(HeapObject *value)
524+
void swift_unownedRelease(HeapObject *value)
536525
SWIFT_CC(RegisterPreservingCC);
537526

538527
/// Increment the weak/unowned retain count by n.
539528
SWIFT_RT_ENTRY_VISIBILITY
540-
extern "C" void swift_unownedRetain_n(HeapObject *value, int n)
529+
void swift_unownedRetain_n(HeapObject *value, int n)
541530
SWIFT_CC(RegisterPreservingCC);
542531

543532
/// Decrement the weak/unowned retain count by n.
544533
SWIFT_RT_ENTRY_VISIBILITY
545-
extern "C" void swift_unownedRelease_n(HeapObject *value, int n)
534+
void swift_unownedRelease_n(HeapObject *value, int n)
546535
SWIFT_CC(RegisterPreservingCC);
547536

548537
/// Increment the strong retain count of an object, aborting if it has
549538
/// been deallocated.
550539
SWIFT_RT_ENTRY_VISIBILITY
551-
extern "C" void swift_unownedRetainStrong(HeapObject *value)
540+
void swift_unownedRetainStrong(HeapObject *value)
552541
SWIFT_CC(RegisterPreservingCC);
553542

554543
/// Increment the strong retain count of an object which may have been
555544
/// deallocated, aborting if it has been deallocated, and decrement its
556545
/// weak/unowned reference count.
557546
SWIFT_RT_ENTRY_VISIBILITY
558-
extern "C" void swift_unownedRetainStrongAndRelease(HeapObject *value)
547+
void swift_unownedRetainStrongAndRelease(HeapObject *value)
559548
SWIFT_CC(RegisterPreservingCC);
560549

561550
/// Aborts if the object has been deallocated.

include/swift/Runtime/Metadata.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,7 +2914,7 @@ using ProtocolConformanceRecord
29142914
/// return metadata
29152915
/// }
29162916
SWIFT_RT_ENTRY_VISIBILITY
2917-
extern "C" const Metadata *
2917+
const Metadata *
29182918
swift_getGenericMetadata(GenericMetadata *pattern,
29192919
const void *arguments)
29202920
SWIFT_CC(RegisterPreservingCC);
@@ -2952,7 +2952,7 @@ swift_allocateGenericValueMetadata(GenericMetadata *pattern,
29522952
/// is ultimately a statement about the user model of overlapping
29532953
/// conformances.
29542954
SWIFT_RT_ENTRY_VISIBILITY
2955-
extern "C" const WitnessTable *
2955+
const WitnessTable *
29562956
swift_getGenericWitnessTable(GenericWitnessTable *genericTable,
29572957
const Metadata *type,
29582958
void * const *instantiationArgs)
@@ -3164,7 +3164,7 @@ swift_getExistentialMetatypeMetadata(const Metadata *instanceType);
31643164
/// \brief Fetch a uniqued metadata for an existential type. The array
31653165
/// referenced by \c protocols will be sorted in-place.
31663166
SWIFT_RT_ENTRY_VISIBILITY
3167-
extern "C" const ExistentialTypeMetadata *
3167+
const ExistentialTypeMetadata *
31683168
swift_getExistentialTypeMetadata(size_t numProtocols,
31693169
const ProtocolDescriptor **protocols)
31703170
SWIFT_CC(RegisterPreservingCC);
@@ -3186,7 +3186,7 @@ swift_getExistentialTypeMetadata(size_t numProtocols,
31863186
/// \return true if the cast succeeded. Depending on the flags,
31873187
/// swift_dynamicCast may fail rather than return false.
31883188
SWIFT_RT_ENTRY_VISIBILITY
3189-
extern "C" bool
3189+
bool
31903190
swift_dynamicCast(OpaqueValue *dest, OpaqueValue *src,
31913191
const Metadata *srcType,
31923192
const Metadata *targetType,
@@ -3201,7 +3201,7 @@ swift_dynamicCast(OpaqueValue *dest, OpaqueValue *src,
32013201
///
32023202
/// \returns the object if the cast succeeds, or null otherwise.
32033203
SWIFT_RT_ENTRY_VISIBILITY
3204-
extern "C" const void *
3204+
const void *
32053205
swift_dynamicCastClass(const void *object, const ClassMetadata *targetType)
32063206
SWIFT_CC(RegisterPreservingCC);
32073207

stdlib/public/runtime/ErrorDefaultImpls.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ using namespace swift;
2222
// @_silgen_name("swift_getDefaultErrorCode")
2323
// func _swift_getDefaultErrorCode<T : Error>(_ x: T) -> Int
2424
SWIFT_CC(swift) SWIFT_RT_ENTRY_VISIBILITY
25-
extern "C" intptr_t swift_getDefaultErrorCode(OpaqueValue *error,
26-
const Metadata *T,
27-
const WitnessTable *Error) {
25+
intptr_t swift_getDefaultErrorCode(OpaqueValue *error,
26+
const Metadata *T,
27+
const WitnessTable *Error) {
2828
intptr_t result;
2929

3030
switch (T->getKind()) {

stdlib/public/runtime/ErrorObject.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ static Class getSwiftNativeNSErrorClass() {
399399
//@_silgen_name("swift_stdlib_getErrorDefaultUserInfo")
400400
//public func _stdlib_getErrorDefaultUserInfo<T : Error>(_ x: UnsafePointer<T>) -> AnyObject
401401
SWIFT_CC(swift) SWIFT_RT_ENTRY_VISIBILITY
402-
extern "C" NSDictionary *swift_stdlib_getErrorDefaultUserInfo(
402+
NSDictionary *swift_stdlib_getErrorDefaultUserInfo(
403403
OpaqueValue *error,
404404
const Metadata *T,
405405
const WitnessTable *Error) {

stdlib/public/runtime/HeapObject.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
using namespace swift;
4343

4444
SWIFT_RT_ENTRY_VISIBILITY
45-
extern "C"
4645
HeapObject *
4746
swift::swift_allocObject(HeapMetadata const *metadata,
4847
size_t requiredSize,
@@ -196,14 +195,12 @@ _swift_release_dealloc(HeapObject *object) SWIFT_CC(RegisterPreservingCC_IMPL)
196195
__attribute__((__noinline__, __used__));
197196

198197
SWIFT_RT_ENTRY_VISIBILITY
199-
extern "C"
200198
void swift::swift_retain(HeapObject *object)
201199
SWIFT_CC(RegisterPreservingCC_IMPL) {
202200
SWIFT_RT_ENTRY_REF(swift_retain)(object);
203201
}
204202

205203
SWIFT_RT_ENTRY_VISIBILITY
206-
extern "C"
207204
void swift::swift_nonatomic_retain(HeapObject *object) {
208205
SWIFT_RT_ENTRY_REF(swift_nonatomic_retain)(object);
209206
}
@@ -215,7 +212,6 @@ void SWIFT_RT_ENTRY_IMPL(swift_nonatomic_retain)(HeapObject *object) {
215212
}
216213

217214
SWIFT_RT_ENTRY_VISIBILITY
218-
extern "C"
219215
void swift::swift_nonatomic_release(HeapObject *object) {
220216
return SWIFT_RT_ENTRY_REF(swift_nonatomic_release)(object);
221217
}
@@ -237,7 +233,6 @@ void SWIFT_RT_ENTRY_IMPL(swift_retain)(HeapObject *object)
237233
}
238234

239235
SWIFT_RT_ENTRY_VISIBILITY
240-
extern "C"
241236
void swift::swift_retain_n(HeapObject *object, uint32_t n)
242237
SWIFT_CC(RegisterPreservingCC_IMPL) {
243238
SWIFT_RT_ENTRY_REF(swift_retain_n)(object, n);
@@ -253,7 +248,6 @@ void SWIFT_RT_ENTRY_IMPL(swift_retain_n)(HeapObject *object, uint32_t n)
253248
}
254249

255250
SWIFT_RT_ENTRY_VISIBILITY
256-
extern "C"
257251
void swift::swift_nonatomic_retain_n(HeapObject *object, uint32_t n)
258252
SWIFT_CC(RegisterPreservingCC_IMPL) {
259253
SWIFT_RT_ENTRY_REF(swift_nonatomic_retain_n)(object, n);
@@ -269,7 +263,6 @@ void SWIFT_RT_ENTRY_IMPL(swift_nonatomic_retain_n)(HeapObject *object, uint32_t
269263
}
270264

271265
SWIFT_RT_ENTRY_VISIBILITY
272-
extern "C"
273266
void swift::swift_release(HeapObject *object)
274267
SWIFT_CC(RegisterPreservingCC_IMPL) {
275268
SWIFT_RT_ENTRY_REF(swift_release)(object);
@@ -354,7 +347,6 @@ void swift::swift_unownedRelease(HeapObject *object)
354347
}
355348

356349
SWIFT_RT_ENTRY_VISIBILITY
357-
extern "C"
358350
void swift::swift_unownedRetain_n(HeapObject *object, int n)
359351
SWIFT_CC(RegisterPreservingCC_IMPL) {
360352
if (!object)
@@ -364,7 +356,6 @@ void swift::swift_unownedRetain_n(HeapObject *object, int n)
364356
}
365357

366358
SWIFT_RT_ENTRY_VISIBILITY
367-
extern "C"
368359
void swift::swift_unownedRelease_n(HeapObject *object, int n)
369360
SWIFT_CC(RegisterPreservingCC_IMPL) {
370361
if (!object)

stdlib/public/runtime/Metadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2770,7 +2770,7 @@ allocateWitnessTable(GenericWitnessTable *genericTable,
27702770
}
27712771

27722772
SWIFT_RT_ENTRY_VISIBILITY
2773-
extern "C" const WitnessTable *
2773+
const WitnessTable *
27742774
swift::swift_getGenericWitnessTable(GenericWitnessTable *genericTable,
27752775
const Metadata *type,
27762776
void * const *instantiationArgs)

stdlib/public/runtime/SwiftObject.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ id swift_dynamicCastObjCProtocolConditional(id object,
12831283
}
12841284

12851285
SWIFT_RT_ENTRY_VISIBILITY
1286-
extern "C" Class swift_getInitializedObjCClass(Class c)
1286+
Class swift_getInitializedObjCClass(Class c)
12871287
SWIFT_CC(RegisterPreservingCC_IMPL) {
12881288
// Used when we have class metadata and we want to ensure a class has been
12891289
// initialized by the Objective-C runtime. We need to do this because the

0 commit comments

Comments
 (0)