mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
This commit is contained in:
@@ -25,6 +25,7 @@ internal final class __BridgingBufferStorage
|
|||||||
internal typealias _BridgingBuffer
|
internal typealias _BridgingBuffer
|
||||||
= ManagedBufferPointer<_BridgingBufferHeader, AnyObject>
|
= ManagedBufferPointer<_BridgingBufferHeader, AnyObject>
|
||||||
|
|
||||||
|
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
|
||||||
extension ManagedBufferPointer
|
extension ManagedBufferPointer
|
||||||
where Header == _BridgingBufferHeader, Element == AnyObject {
|
where Header == _BridgingBufferHeader, Element == AnyObject {
|
||||||
internal init(_ count: Int) {
|
internal init(_ count: Int) {
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ extension ManagedBuffer {
|
|||||||
/// idea to store this information in the "header" area when
|
/// idea to store this information in the "header" area when
|
||||||
/// an instance is created.
|
/// an instance is created.
|
||||||
@inlinable
|
@inlinable
|
||||||
|
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
|
||||||
public final var capacity: Int {
|
public final var capacity: Int {
|
||||||
let storageAddr = UnsafeMutableRawPointer(Builtin.bridgeToRawPointer(self))
|
let storageAddr = UnsafeMutableRawPointer(Builtin.bridgeToRawPointer(self))
|
||||||
let endAddr = storageAddr + _swift_stdlib_malloc_size(storageAddr)
|
let endAddr = storageAddr + _swift_stdlib_malloc_size(storageAddr)
|
||||||
@@ -197,6 +198,7 @@ public struct ManagedBufferPointer<Header, Element> {
|
|||||||
/// properties. The `deinit` of `bufferClass` must destroy its
|
/// properties. The `deinit` of `bufferClass` must destroy its
|
||||||
/// stored `Header` and any constructed `Element`s.
|
/// stored `Header` and any constructed `Element`s.
|
||||||
@inlinable
|
@inlinable
|
||||||
|
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
|
||||||
public init(
|
public init(
|
||||||
bufferClass: AnyClass,
|
bufferClass: AnyClass,
|
||||||
minimumCapacity: Int,
|
minimumCapacity: Int,
|
||||||
@@ -329,6 +331,7 @@ extension ManagedBufferPointer {
|
|||||||
/// idea to store this information in the "header" area when
|
/// idea to store this information in the "header" area when
|
||||||
/// an instance is created.
|
/// an instance is created.
|
||||||
@inlinable
|
@inlinable
|
||||||
|
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
|
||||||
public var capacity: Int {
|
public var capacity: Int {
|
||||||
return (
|
return (
|
||||||
_capacityInBytes &- ManagedBufferPointer._elementOffset
|
_capacityInBytes &- ManagedBufferPointer._elementOffset
|
||||||
@@ -431,6 +434,7 @@ extension ManagedBufferPointer {
|
|||||||
|
|
||||||
/// The actual number of bytes allocated for this object.
|
/// The actual number of bytes allocated for this object.
|
||||||
@inlinable
|
@inlinable
|
||||||
|
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
|
||||||
internal var _capacityInBytes: Int {
|
internal var _capacityInBytes: Int {
|
||||||
return _swift_stdlib_malloc_size(_address)
|
return _swift_stdlib_malloc_size(_address)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// RUN: %target-run-simple-swift | %FileCheck %s
|
// RUN: %target-run-simple-swift | %FileCheck %s
|
||||||
// REQUIRES: executable_test
|
// REQUIRES: executable_test
|
||||||
|
// XFAIL: OS=openbsd
|
||||||
|
|
||||||
import Swift
|
import Swift
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// RUN: %target-run-simple-swift
|
// RUN: %target-run-simple-swift
|
||||||
// REQUIRES: executable_test
|
// REQUIRES: executable_test
|
||||||
|
// XFAIL: OS=openbsd
|
||||||
|
|
||||||
import StdlibUnittest
|
import StdlibUnittest
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user