From a90b287e93a44444fe99e6195f17ba55265a4a1c Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Thu, 23 Oct 2025 17:38:41 -0400 Subject: [PATCH] Adopt `@c`. This PR adopts the new `@c` attribute from [SE-0495](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0495-cdecl.md). I've gated adoption on Swift 6.3.1 to give the compiler team time to finish implementing the feature. Older compilers will continue to use `@_cdecl`. --- Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift | 4 ++++ Sources/_TestingInterop/FallbackEventHandler.swift | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift b/Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift index 2ff10c964..b0f1c658f 100644 --- a/Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift +++ b/Sources/Testing/ABI/EntryPoints/ABIEntryPoint.swift @@ -71,7 +71,11 @@ extension ABI.v0 { /// - Note: This function's name is prefixed with `swt_` instead of /// `swift_testing_` for binary compatibility reasons. Future ABI entry point /// functions should use the `swift_testing_` prefix instead. +#if compiler(>=6.3.1) +@c(swt_abiv0_getEntryPoint) +#else @_cdecl("swt_abiv0_getEntryPoint") +#endif @usableFromInline func abiv0_getEntryPoint() -> UnsafeRawPointer { unsafeBitCast(ABI.v0.entryPoint, to: UnsafeRawPointer.self) } diff --git a/Sources/_TestingInterop/FallbackEventHandler.swift b/Sources/_TestingInterop/FallbackEventHandler.swift index 2e33cd04d..269b196c2 100644 --- a/Sources/_TestingInterop/FallbackEventHandler.swift +++ b/Sources/_TestingInterop/FallbackEventHandler.swift @@ -55,7 +55,11 @@ package typealias FallbackEventHandler = @Sendable @convention(c) ( /// Get the current fallback event handler. /// /// - Returns: The currently-set handler function, if any. +#if compiler(>=6.3.1) +@c +#else @_cdecl("_swift_testing_getFallbackEventHandler") +#endif @usableFromInline package func _swift_testing_getFallbackEventHandler() -> FallbackEventHandler? { #if SWT_TARGET_OS_APPLE && !SWT_NO_OS_UNFAIR_LOCK @@ -83,7 +87,11 @@ package func _swift_testing_getFallbackEventHandler() -> FallbackEventHandler? { /// The fallback event handler can only be installed once per process, typically /// by the first testing library to run. If this function has already been /// called and the handler set, it does not replace the previous handler. +#if compiler(>=6.3.1) +@c +#else @_cdecl("_swift_testing_installFallbackEventHandler") +#endif @usableFromInline package func _swift_testing_installFallbackEventHandler(_ handler: FallbackEventHandler) -> CBool { #if SWT_TARGET_OS_APPLE && !SWT_NO_OS_UNFAIR_LOCK