forked from swiftlang/swift
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom-print.swift
29 lines (25 loc) · 794 Bytes
/
custom-print.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -enable-experimental-feature Extern -enable-experimental-feature Embedded -enforce-exclusivity=none %s -c -o %t/a.o
// RUN: %target-clang %t/a.o -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: swift_feature_Embedded
// REQUIRES: swift_feature_Extern
@_extern(c,"putchar")
@discardableResult
func putchar(_:CInt)-> CInt
public func print(_ s:StaticString, terminator:StaticString="\n") {
var p = s.utf8Start
while p.pointee != 0 {
putchar(CInt(p.pointee))
p += 1
}
p = terminator.utf8Start
while p.pointee != 0 {
putchar(CInt(p.pointee))
p += 1
}
}
print("Hello, Embedded Swift!")
// CHECK: Hello, Embedded Swift!