Commit Graph

134 Commits

Author SHA1 Message Date
Nate Chandler
b12def9c6a [BitwiseCopyable] Deprecate unbound overloads.
The unconstrained overloads of loadUnaligned and storeBytes were
deprecated in SE-0426.
2024-04-25 11:44:15 -07:00
Nate Chandler
f9ad81e106 [BitwiseCopyable] Remove #ifs. 2024-04-25 11:44:15 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Allan Shortlidge
a1dacc12d7 stdlib: Make typed throws ABI placeholders properly @usableFromInline.
Functions that are used in public `@inlinable` function bodies can't be marked
`@_spi` nor can they be made obsolete. Also, they must retain `rethrows` so
that use of these entry points from other `rethrows` functions is accepted.

Builds on https://github.com/apple/swift/pull/72365. Once we no longer have to
support pre-`$TypedThrows` compilers, all of this can be reverted.

Part of rdar://125138945
2024-03-27 14:57:56 -07:00
Karoy Lorentey
e88750eb0c [stdlib] Apply review notes from @glessard (thanks!) 2024-03-18 11:09:08 -07:00
Karoy Lorentey
d70f197c24 [stdlib] Update SwiftStdlibLegacyABI convention to use @available(swift, obsoleted: 1)
Using version `2` here is just weird for no reason.
2024-03-18 11:03:49 -07:00
Karoy Lorentey
3507a0cf8c [stdlib] Add support for noncopyables to withUnsafePointer(to:) family 2024-03-18 11:03:49 -07:00
Karoy Lorentey
5ae757181e [stdlib] UnsafeRawBufferPointer: new interactions with noncopyable types 2024-03-18 11:03:49 -07:00
Allan Shortlidge
20a8399488 stdlib: Guard @inlinable use of withMemoryRebound() with #if $TypedThrows.
Older compilers can no longer see the definition of `withMemoryRebound()` now
that it has adopted typed throws (https://github.com/apple/swift/pull/72036).

Resolves rdar://124540428
2024-03-13 11:38:24 -07:00
Guillaume Lessard
805dd70cfe Merge pull request #72074 from glessard/toplevel-withbytes-typed-throws
[stdlib] convert `withUnsafeBytes()` to typed throws
2024-03-08 08:55:08 -08:00
Guillaume Lessard
207ae32107 [stdlib] add _withUnprotectedUnsafeMutableBytes() 2024-03-05 02:25:52 -08:00
Guillaume Lessard
528dd0967f [stdlib] convert withUnsafeMutableBytes() to typed throws 2024-03-05 02:12:04 -08:00
Guillaume Lessard
68088bc4e1 [stdlib] convert inout-taking withUnsafeBytes() to typed throws 2024-03-05 02:10:38 -08:00
Guillaume Lessard
f2dcb2f058 [stdlib] convert withUnsafeBytes() to typed throws 2024-03-05 02:10:38 -08:00
Guillaume Lessard
8c0db3fe7e Merge pull request #72075 from Catfish-Man/this-pointer-is-raw
Make UnsafeRawBufferPointer.loadUnaligned inlinable to match other pointer load methods
2024-03-04 23:57:21 -08:00
David Smith
df8485fe87 Make UnsafeRawBufferPointer.loadUnaligned inlinable to match other pointer load methods 2024-03-04 16:00:15 -08:00
Guillaume Lessard
6befe66181 [stdlib] convert U[M]R[B]P.withMemoryRebound() to typed throws 2024-03-01 19:07:46 -08:00
Guillaume Lessard
4e36f5616d [stdlib] operator precedence strikes again 2024-01-14 17:13:24 -08:00
Stephen Canon
c7d50087b0 Check the base address against the element alignment rather than stride
Stride is the gap between elements, not the alignment that each element must satisfy (stride need not even be a power of two).
2024-01-13 16:59:51 -05:00
Nate Chandler
b7f5171b83 [stdlib] BitwiseCopyable loadUnaligned overloads.
The new overloads will make use the new BitwiseCopyableArchetypeTypeInfo
to avoid the extra copy that is currently done.
2023-12-05 17:21:05 -08:00
Nate Cook
2c244b9698 Fix precondition in UMRBP.initialize(as:fromContentsOf:)
This precondition checks to make sure that the content-providing
collection isn't larger than the allocated buffer, but was preventing
using a buffer that is the exact same size as the collection.
2023-10-25 17:17:36 -05:00
Pavel Yaskevich
a0dfab9ab2 [SE-0331] Mark unsafe pointer conformances to Sendable as explicitly unavailable
This is a preferred way to make sure that Sendable inference doesn't
happen for these types because they are marked as @frozen.
2023-10-10 21:42:46 -07:00
Kuba Mracek
92b075b518 [embedded] Drop several #ifs and fatalError()s by adding an unavailable ExpressibleByStringInterpolation String conformance 2023-09-16 13:40:25 -07:00
Kuba Mracek
ae2e903574 [embedded] Build an initial embedded Swift standard library
This isn't a "complete" port of the standard library for embedded Swift, but
something that should serve as a starting point for further iterations on the
stdlib.

- General CMake logic for building a library as ".swiftmodule only" (ONLY_SWIFTMODULE).
- CMake logic in stdlib/public/core/CMakeLists.txt to start building the embedded stdlib for a handful of hardcoded target triples.
- Lots of annotations throughout the standard library to make types, functions, protocols unavailable in embedded Swift (@_unavailableInEmbedded).
- Mainly this is about stdlib functionality that relies on existentials, type erasure, metatypes, reflection, string interpolations.
- We rely on function body removal of unavailable functions to eliminate the actual problematic SIL code (existentials).
- Many .swift files are not included in the compilation of embedded stdlib at all, to simplify the scope of the annotations.
- EmbeddedStubs.swift is used to stub out (as unavailable and fatalError'd) the missing functionality.
2023-09-16 12:38:46 -07:00
Cory Benfield
9cb3641ce8 Remove checks in UR[M]BP.Iterator.next() (#62965)
Swift tends to emit unnecessary checks and traps when iterating unsafe
raw buffer pointers. These traps are confirming that the position
pointer isn't nil, but this check is redundant with the bounds check
that is already present. We can safely remove it.
2023-01-12 11:04:42 -05:00
Guillaume Lessard
2689b6044b Merge pull request #41608 from glessard/se-pointer-family-initialization 2022-09-13 22:00:59 -06:00
Guillaume Lessard
1152347699 [stdlib] remove primary associated type from copyBytes
- this caused an unexpected test failure, will change separately.
2022-09-12 14:18:47 -06:00
Guillaume Lessard
ffa7b0e78c [se-0370] add notes regarding overlapping memory regions 2022-09-08 18:23:45 -06:00
Erik Eckstein
9c1e7cac0f stdlib: fix compilation error when compiling with an old compiler
Fix wrong/missing check for `$BuiltinUnprotectedAddressOf` around the new "unprotectedAddressOf" builtins.

rdar://99713099
2022-09-08 23:05:17 +02:00
Erik Eckstein
0f8dd3a551 stdlib: opt out of stack protection in places where there can't be buffer overflows.
We trust the internal implementation of the stdlib to not cause any unintentional buffer overflows.
In such cases we can use the "unprotected" address-to-pointer conversions.
This avoids inserting stack protections where it's not needed.
2022-09-08 08:42:25 +02:00
Erik Eckstein
ba135dc493 stdlib: add underscored "withUnprotected..Pointer" functions
Those functions work the same way as their "unprotected" counterparts, except that they don't trigger stack protection for the pointers.

* `_withUnprotectedUnsafeMutablePointer`
* `_withUnprotectedUnsafePointer`
* `_withUnprotectedUnsafeBytes` (two times)
2022-09-08 08:42:25 +02:00
Guillaume Lessard
44a349f8e0 [se-0370] edit doc-comments for consistency 2022-09-07 15:22:49 -06:00
Guillaume Lessard
88225a2584 [se-0370] some consistency tweaks 2022-09-07 10:07:10 -06:00
Guillaume Lessard
6512840469 [stdlib] update copyBytes with primary associated type 2022-09-07 10:07:04 -06:00
Guillaume Lessard
c2c432c9d2 [se-0370] re-implement in accordance with updated proposal 2022-08-30 11:05:41 -06:00
Guillaume Lessard
f5ffe09c53 [se-0370] fix editing errors 2022-08-26 17:36:40 -06:00
Guillaume Lessard
26e5c43aa3 [se-0370] update documentation to track proposal
for the functions involving `fromContentsOf:`.
2022-08-26 17:36:40 -06:00
Guillaume Lessard
00aaa07daf [stdlib] improve doc-comments 2022-08-26 17:36:40 -06:00
Guillaume Lessard
831a87fd36 [stdlib] make additions non-abi 2022-08-26 17:36:40 -06:00
Guillaume Lessard
2e3b5e6655 [stdlib] more memory initialization functions for UMRBP 2022-08-26 17:36:40 -06:00
Guillaume Lessard
92087a8f62 [stdlib] add explanations to _debugPrecondition calls 2022-08-18 15:37:25 -06:00
Guillaume Lessard
a74f22dadf [docs] fix a repeated typo 2022-06-29 18:19:34 -06:00
Guillaume Lessard
e353e2f568 [stdlib] document compatibility entry point silgen names better 2022-06-29 16:21:55 -06:00
Guillaume Lessard
6d36a36dd9 [stdlib] improve silgen names and better document intention 2022-06-29 16:20:34 -06:00
Karoy Lorentey
35fc9ea772 Merge pull request #59117 from glessard/se0349-doctweak
[doc] mention `loadUnaligned` in the description of `UnsafeRawBufferPointer`
2022-06-10 11:00:59 -07:00
Guillaume Lessard
0895934303 [docs] fix a parameter description for storeBytes 2022-06-01 09:04:43 -06:00
Guillaume Lessard
11138424a7 [docs] clarify docs for load, loadUnaligned and storeBytes
- outdated and incorrect information removed
2022-05-31 15:55:09 -06:00
Guillaume Lessard
d6165cd83d [doc] mention loadUnaligned in URBP description 2022-05-26 14:09:00 -06:00
Guillaume Lessard
a368e59564 [stdlib] incorporate proposal number in silgen name 2022-04-18 12:50:19 -06:00
Guillaume Lessard
1828aca9f0 [stdlib] update UnsafeMutableRawBufferPointer.storeBytes
- preserve previous version for ABI and source stability.
- add new version without alignment restriction.
- add explicit POD type enforcement in new version.
2022-04-14 17:23:53 -06:00