swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.22k stars 10.32k forks source link

Support @_silgen_name C imports for SE-0324 #68332

Open glessard opened 12 months ago

glessard commented 12 months ago

In standard library modules, many C functions are imported using the following pattern:

@_silgen_name("_swift_stdlib_getUnsafeArgvArgc")
internal func _swift_stdlib_getUnsafeArgvArgc(_: UnsafeMutablePointer<Int32>)
  -> UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>

not followed by a function body. This is special-cased by the compiler.

Functions imported this way do not benefit from the SE-0324 relaxed pointer semantics. They should have the same affordance as other C functions. This pattern also appears with the @objc attribute, but much more rarely than with @_silgen_name.

Tracked as rdar://114794258

glessard commented 8 months ago

Functions imported this way should use the newer @extern(c) syntax.