Files
swift-mirror/test/Interpreter/generic_ref_counts.swift
3405691582 cd7570fdee ManagedBuffer capacity is unavailable on OpenBSD.
On OpenBSD, malloc introspection (e.g., malloc_usable_size or
malloc_size) is not provided by the platform allocator. Since allocator
introspection is currently a load-bearing piece of functionality for
ManagedBuffer and ManagedBufferPointer, pending any API changes, as a
stopgap measure, this commit marks methods in ManagedBuffer and
ManagedBufferPointer calling _swift_stdlib_malloc_size and methods
dependent thereon unavailable on OpenBSD.

This may induce some compatibility issues for some files, but at least
this change ensures that we can get stdlib to build on this platform
until the evolution process addresses this problem more thoroughly.
2020-09-09 18:57:58 -04:00

56 lines
1.1 KiB
Swift

// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test
// XFAIL: OS=openbsd
import Swift
// Regression test for <rdar://problem/16119895>.
struct Generic<T> {
typealias Storage = ManagedBuffer<Int,T>
init() {
buffer = ManagedBufferPointer(
bufferClass: Storage.self, minimumCapacity: 0) { _,_ in 0 }
}
mutating func isUniqueReference() -> Bool {
return buffer.isUniqueReference()
}
var buffer: ManagedBufferPointer<Int, T>
}
func g0() {
var x = Generic<Int>()
// CHECK: true
print(x.isUniqueReference())
// CHECK-NEXT: true
print(x.buffer.isUniqueReference())
}
g0()
struct NonGeneric {
typealias T = Int
typealias Storage = ManagedBuffer<Int,T>
init() {
buffer = ManagedBufferPointer(
bufferClass: Storage.self, minimumCapacity: 0) { _,_ in 0 }
}
mutating func isUniqueReference() -> Bool {
return buffer.isUniqueReference()
}
var buffer: ManagedBufferPointer<Int, T>
}
func g1() {
var x = NonGeneric()
// CHECK-NEXT: true
print(x.isUniqueReference())
// CHECK-NEXT: true
print(x.buffer.isUniqueReference())
}
g1()