Skip to content

[stdlib] convert withUnsafeBytes() to typed throws #72074

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 6 commits into from
Mar 8, 2024

Conversation

glessard
Copy link
Contributor

@glessard glessard commented Mar 5, 2024

Part of the ongoing conversion of standard library rethrows functions, after SE-0413.

This converts the top-level withUnsafe[Mutable]Bytes(of:_:) functions, and their corresponding no-stack-protection equivalents. There was no _withUnprotectedUnsafeMutableBytes() previously — added here.

@glessard glessard requested a review from a team as a code owner March 5, 2024 00:01
@glessard
Copy link
Contributor Author

glessard commented Mar 5, 2024

@swift-ci please test

@glessard glessard changed the title [stdlib] convert withUnsafeBytes() to typed throws [stdlib] convert withUnsafeBytes() to typed throws Mar 5, 2024
@glessard glessard force-pushed the toplevel-withbytes-typed-throws branch 2 times, most recently from f6c0f4f to b2f28d0 Compare March 5, 2024 06:30
@glessard
Copy link
Contributor Author

glessard commented Mar 5, 2024

@swift-ci please test

@glessard glessard force-pushed the toplevel-withbytes-typed-throws branch from b2f28d0 to b99900f Compare March 5, 2024 10:16
@glessard glessard force-pushed the toplevel-withbytes-typed-throws branch from b99900f to e02d8ab Compare March 5, 2024 10:26
@glessard
Copy link
Contributor Author

glessard commented Mar 5, 2024

@swift-ci please test

Update test/api-digester/stability-stdlib-abi-without-asserts.test
@glessard
Copy link
Contributor Author

glessard commented Mar 5, 2024

@swift-ci please test

@glessard
Copy link
Contributor Author

glessard commented Mar 5, 2024

@swift-ci please test linux platform

@glessard
Copy link
Contributor Author

glessard commented Mar 5, 2024

@swift-ci please test windows platform

_ body: (UnsafeMutableRawBufferPointer) throws(E) -> Result
) throws(E) -> Result {
let pointer = UnsafeMutableRawPointer(Builtin.addressof(&value))
return try body(.init(start: pointer, count: MemoryLayout<T>.size))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason for writing this way instead of how the old thing was doing it? Not opposed, just curious 🙂

Copy link
Contributor Author

@glessard glessard Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old way crashed the compiler; going straight to the builtin is a workaround. (Not entirely successful, it seems.)

Copy link
Contributor

@Azoy Azoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glessard
Copy link
Contributor Author

glessard commented Mar 8, 2024

The previous failure is likely fixed by #72152

@glessard
Copy link
Contributor Author

glessard commented Mar 8, 2024

@swift-ci please test

@glessard glessard merged commit 805dd70 into swiftlang:main Mar 8, 2024
@glessard glessard deleted the toplevel-withbytes-typed-throws branch March 8, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants