Skip to content

Commit cd7570f

Browse files
committed
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.
1 parent b59910e commit cd7570f

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

stdlib/public/core/BridgingBuffer.swift

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ internal final class __BridgingBufferStorage
2525
internal typealias _BridgingBuffer
2626
= ManagedBufferPointer<_BridgingBufferHeader, AnyObject>
2727

28+
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
2829
extension ManagedBufferPointer
2930
where Header == _BridgingBufferHeader, Element == AnyObject {
3031
internal init(_ count: Int) {

stdlib/public/core/ManagedBuffer.swift

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ extension ManagedBuffer {
8383
/// idea to store this information in the "header" area when
8484
/// an instance is created.
8585
@inlinable
86+
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
8687
public final var capacity: Int {
8788
let storageAddr = UnsafeMutableRawPointer(Builtin.bridgeToRawPointer(self))
8889
let endAddr = storageAddr + _swift_stdlib_malloc_size(storageAddr)
@@ -197,6 +198,7 @@ public struct ManagedBufferPointer<Header, Element> {
197198
/// properties. The `deinit` of `bufferClass` must destroy its
198199
/// stored `Header` and any constructed `Element`s.
199200
@inlinable
201+
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
200202
public init(
201203
bufferClass: AnyClass,
202204
minimumCapacity: Int,
@@ -329,6 +331,7 @@ extension ManagedBufferPointer {
329331
/// idea to store this information in the "header" area when
330332
/// an instance is created.
331333
@inlinable
334+
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
332335
public var capacity: Int {
333336
return (
334337
_capacityInBytes &- ManagedBufferPointer._elementOffset
@@ -431,6 +434,7 @@ extension ManagedBufferPointer {
431434

432435
/// The actual number of bytes allocated for this object.
433436
@inlinable
437+
@available(OpenBSD, unavailable, message: "malloc_size is unavailable.")
434438
internal var _capacityInBytes: Int {
435439
return _swift_stdlib_malloc_size(_address)
436440
}

test/Interpreter/generic_ref_counts.swift

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %target-run-simple-swift | %FileCheck %s
22
// REQUIRES: executable_test
3+
// XFAIL: OS=openbsd
34

45
import Swift
56

test/stdlib/ManagedBuffer.swift

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212
// RUN: %target-run-simple-swift
1313
// REQUIRES: executable_test
14+
// XFAIL: OS=openbsd
1415

1516
import StdlibUnittest
1617

0 commit comments

Comments
 (0)