diff --git a/swift-daemon-api/Sources/CliContext.swift b/swift-daemon-api/Sources/CliContext.swift index 2e64e409..fdaae650 100644 --- a/swift-daemon-api/Sources/CliContext.swift +++ b/swift-daemon-api/Sources/CliContext.swift @@ -101,11 +101,24 @@ private func cliPuts(_ context: UnsafeMutablePointer?, _ str: Unsaf } } +// The va_list C type on i386, armv7 and i86_64 is CVaListPointer, whereas on +// arm64 it is Optional. +#if arch(arm64) + +private func cliVprintf(_ context: UnsafeMutablePointer?, _ fmt: UnsafePointer?, _ ap: CVaListPointer?) -> Void { + let str = NSString(format: String(cString: fmt!), arguments: ap!) + _self(context).putString(String(data: str.data(using: String.Encoding.utf16.rawValue)!, encoding:.utf16)!) +} + +#else + private func cliVprintf(_ context: UnsafeMutablePointer?, _ fmt: UnsafePointer?, _ ap: CVaListPointer) -> Void { let str = NSString(format: String(cString: fmt!), arguments: ap) _self(context).putString(String(data: str.data(using: String.Encoding.utf16.rawValue)!, encoding:.utf16)!) } +#endif + private func cliPutLong(_ context: UnsafeMutablePointer?, _ value: Int64, _ delim: UnsafePointer?) -> Void { _self(context).putLong(value, delim != nil ? String(cString: delim!) : nil) }