Skip to content

Commit 8dd56d4

Browse files
committed
[embedded] Use the correct standard putchar signature: func putchar(_: CInt) -> CInt
1 parent d5de856 commit 8dd56d4

11 files changed

+45
-34
lines changed

stdlib/public/core/EmbeddedPrint.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,25 @@ import SwiftShims
1717
// printing to not need to heap allocate).
1818

1919
@_silgen_name("putchar")
20-
func putchar(_: UInt8)
20+
@discardableResult
21+
func putchar(_: CInt) -> CInt
2122

2223
public func print(_ string: StaticString, terminator: StaticString = "\n") {
2324
var p = string.utf8Start
2425
while p.pointee != 0 {
25-
putchar(p.pointee)
26+
putchar(CInt(p.pointee))
2627
p += 1
2728
}
2829
p = terminator.utf8Start
2930
while p.pointee != 0 {
30-
putchar(p.pointee)
31+
putchar(CInt(p.pointee))
3132
p += 1
3233
}
3334
}
3435
3536
func printCharacters(_ buf: UnsafeRawBufferPointer) {
3637
for c in buf {
37-
putchar(c)
38+
putchar(CInt(c))
3839
}
3940
}
4041

test/embedded/array-to-pointer.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
// REQUIRES: OS=macosx || OS=linux-gnu
1111

1212
@_silgen_name("putchar")
13-
func putchar(_: UInt8)
13+
@discardableResult
14+
func putchar(_: CInt) -> CInt
1415

1516
public func print(_ s: StaticString, terminator: StaticString = "\n") {
1617
var p = s.utf8Start
1718
while p.pointee != 0 {
18-
putchar(p.pointee)
19+
putchar(CInt(p.pointee))
1920
p += 1
2021
}
2122
p = terminator.utf8Start
2223
while p.pointee != 0 {
23-
putchar(p.pointee)
24+
putchar(CInt(p.pointee))
2425
p += 1
2526
}
2627
}

test/embedded/arrays.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
// REQUIRES: OS=macosx || OS=linux-gnu
1111

1212
@_silgen_name("putchar")
13-
func putchar(_: UInt8)
13+
@discardableResult
14+
func putchar(_: CInt) -> CInt
1415

1516
public func print(_ s: StaticString, terminator: StaticString = "\n") {
1617
var p = s.utf8Start
1718
while p.pointee != 0 {
18-
putchar(p.pointee)
19+
putchar(CInt(p.pointee))
1920
p += 1
2021
}
2122
p = terminator.utf8Start
2223
while p.pointee != 0 {
23-
putchar(p.pointee)
24+
putchar(CInt(p.pointee))
2425
p += 1
2526
}
2627
}

test/embedded/collection.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
// REQUIRES: OS=macosx || OS=linux-gnu
1111

1212
@_silgen_name("putchar")
13-
func putchar(_: UInt8)
13+
@discardableResult
14+
func putchar(_: CInt) -> CInt
1415

1516
public func print(_ s: StaticString, terminator: StaticString = "\n") {
1617
var p = s.utf8Start
1718
while p.pointee != 0 {
18-
putchar(p.pointee)
19+
putchar(CInt(p.pointee))
1920
p += 1
2021
}
2122
p = terminator.utf8Start
2223
while p.pointee != 0 {
23-
putchar(p.pointee)
24+
putchar(CInt(p.pointee))
2425
p += 1
2526
}
2627
}

test/embedded/custom-print.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
// REQUIRES: OS=macosx || OS=linux-gnu
99

1010
@_silgen_name("putchar")
11-
func putchar(_: UInt8)
11+
@discardableResult
12+
func putchar(_: CInt) -> CInt
1213

1314
public func print(_ s: StaticString, terminator: StaticString = "\n") {
1415
var p = s.utf8Start
1516
while p.pointee != 0 {
16-
putchar(p.pointee)
17+
putchar(CInt(p.pointee))
1718
p += 1
1819
}
1920
p = terminator.utf8Start
2021
while p.pointee != 0 {
21-
putchar(p.pointee)
22+
putchar(CInt(p.pointee))
2223
p += 1
2324
}
2425
}

test/embedded/dependencies.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@
2929
// UNSUPPORTED: OS=linux-gnu && CPU=aarch64
3030

3131
@_silgen_name("putchar")
32-
func putchar(_: UInt8)
32+
@discardableResult
33+
func putchar(_: CInt) -> CInt
3334

3435
public func print(_ s: StaticString, terminator: StaticString = "\n") {
3536
var p = s.utf8Start
3637
while p.pointee != 0 {
37-
putchar(p.pointee)
38+
putchar(CInt(p.pointee))
3839
p += 1
3940
}
4041
p = terminator.utf8Start
4142
while p.pointee != 0 {
42-
putchar(p.pointee)
43+
putchar(CInt(p.pointee))
4344
p += 1
4445
}
4546
}

test/embedded/deserialize-vtables.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ extension StaticString {
2222
}
2323

2424
@_silgen_name("putchar")
25-
func putchar(_: UInt8)
25+
@discardableResult
26+
func putchar(_: CInt) -> CInt
2627

2728
extension Array<UInt8> {
2829
func print() {
2930
for byte in self {
30-
putchar(byte)
31+
putchar(CInt(byte))
3132
}
3233
putchar(10)
3334
}

test/embedded/lto.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
// REQUIRES: no_asan
1414

1515
@_silgen_name("putchar")
16-
func putchar(_: UInt8)
16+
@discardableResult
17+
func putchar(_: CInt) -> CInt
1718

1819
public func print(_ s: StaticString, terminator: StaticString = "\n") {
1920
var p = s.utf8Start
2021
while p.pointee != 0 {
21-
putchar(p.pointee)
22+
putchar(CInt(p.pointee))
2223
p += 1
2324
}
2425
p = terminator.utf8Start
2526
while p.pointee != 0 {
26-
putchar(p.pointee)
27+
putchar(CInt(p.pointee))
2728
p += 1
2829
}
2930
}

test/embedded/modules-globals-exec.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@ public func foo() {
2525
import MyModule
2626

2727
@_silgen_name("putchar")
28-
func putchar(_: UInt8)
28+
@discardableResult
29+
func putchar(_: CInt) -> CInt
2930

3031
public func print(_ s: StaticString, terminator: StaticString = "\n") {
3132
var p = s.utf8Start
3233
while p.pointee != 0 {
33-
putchar(p.pointee)
34+
putchar(CInt(p.pointee))
3435
p += 1
3536
}
3637
p = terminator.utf8Start
3738
while p.pointee != 0 {
38-
putchar(p.pointee)
39+
putchar(CInt(p.pointee))
3940
p += 1
4041
}
4142
}

test/embedded/modules-print-exec.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
// BEGIN MyModule.swift
1515

1616
@_silgen_name("putchar")
17-
func putchar(_: UInt8)
17+
@discardableResult
18+
func putchar(_: CInt) -> CInt
1819

19-
public func print(_ s: StaticString, terminator: StaticString) {
20+
public func print(_ s: StaticString, terminator: StaticString = "\n") {
2021
var p = s.utf8Start
2122
while p.pointee != 0 {
22-
putchar(p.pointee)
23+
putchar(CInt(p.pointee))
2324
p += 1
2425
}
2526
p = terminator.utf8Start
2627
while p.pointee != 0 {
27-
putchar(p.pointee)
28+
putchar(CInt(p.pointee))
2829
p += 1
2930
}
3031
}

0 commit comments

Comments
 (0)