Skip to content

[stdlib/private][os log] Minor changes to the new os log overlay #29630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions stdlib/private/OSLog/OSLogIntegerTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ extension OSLogInterpolation {
appendInteger(number, format: format, privacy: privacy)
}

@_semantics("constant_evaluable")
@inlinable
@_optimize(none)
public mutating func appendInterpolation(
_ number: @autoclosure @escaping () -> UInt,
format: IntFormat = .decimal,
privacy: Privacy = .public
) {
appendInteger(number, format: format, privacy: privacy)
}

/// Given an integer, create and append a format specifier for the integer to the
/// format string property. Also, append the integer along with necessary headers
/// to the OSLogArguments property.
Expand Down Expand Up @@ -154,10 +165,11 @@ extension OSLogArguments {
}

/// Return the number of bytes needed for serializing an integer argument as
/// specified by os_log. This function must be constant evaluable.
@_semantics("constant_evaluable")
@inlinable
@_optimize(none)
/// specified by os_log. This function must be constant evaluable. Note that
/// it is marked transparent instead of @inline(__always) as it is used in
/// optimize(none) functions.
@_transparent
@usableFromInline
internal func sizeForEncoding<T>(
_ type: T.Type
) -> Int where T : FixedWidthInteger {
Expand Down
7 changes: 4 additions & 3 deletions stdlib/private/OSLog/OSLogMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ public enum Privacy {
@_optimize(none)
public var maxOSLogArgumentCount: UInt8 { return 48 }

@_semantics("constant_evaluable")
@inlinable
@_optimize(none)
/// Note that this is marked transparent instead of @inline(__always) as it is
/// used in optimize(none) functions.
@_transparent
@usableFromInline
internal var logBitsPerByte: Int { return 3 }

/// Represents a string interpolation passed to the log APIs.
Expand Down
8 changes: 4 additions & 4 deletions stdlib/private/OSLog/OSLogStringTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ extension OSLogArguments {
/// bitWidth property, and since MemoryLayout is not supported by the constant
/// evaluator, this function returns the byte size of Int, which must equal the
/// word length of the target architecture and hence the pointer size.
/// This function must be constant evaluable.
@_semantics("constant_evaluable")
@inlinable
@_optimize(none)
/// This function must be constant evaluable. Note that it is marked transparent
/// instead of @inline(__always) as it is used in optimize(none) functions.
@_transparent
@usableFromInline
internal func pointerSizeInBytes() -> Int {
return Int.bitWidth &>> logBitsPerByte
}
Expand Down
Loading