Commit Graph

66 Commits

Author SHA1 Message Date
Doug Gregor
22eecacc35 Adopt unsafe annotations throughout the standard library 2025-02-26 14:28:01 -08:00
Allan Shortlidge
20d97556ae stdlib: Remove #if $TypedThrows guards.
https://github.com/swiftlang/swift/pull/72612 can be reverted because it is no
longer necessary for the interface of the stdlib to be compatible with
compilers without `$TypedThrows` support.
2024-07-08 16:52:52 -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
Guillaume Lessard
8459d0616d [stdlib] make swiftinterfaces compatible with older toolchains 2024-03-15 16:50:12 -07:00
Max Desiatov
633d5bc45a Enable x86_64 and i686 ELF triples for embedded Swift (#70642)
This is just as useful for x86 bare metal as the already enabled `arm*-none-none-eabi` triples.
2024-01-26 21:39:17 +00: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
Karoy Lorentey
6d255658ca Merge pull request #39994 from lorentey/adopt-availability-macros
[stdlib] Adopt availability macros
2021-11-01 14:45:33 -07:00
Karoy Lorentey
1dbcf23515 [stdlib] Availability macros don't work in inlinable code 😩 2021-10-31 15:00:59 -07:00
Karoy Lorentey
8ed81ae063 [stdlib] Adopt availability macros 2021-10-31 15:00:58 -07:00
Alex Martini
1186fc7f13 Remove "iff" from doc comments.
This abbreviation for "if and only if" is confusing to those not coming
from a background in formal mathematics, and is frequently reported as a
type by developers reading the documentation.

This commit also changes doc comments in internal and private members,
which don't become part of the public documentation, because omitting
"iff" everywhere makes it much easier to check for any later changes
that reintroduce it.
2021-10-29 10:16:27 -07:00
Alex Martini
4b2f4874b3 Use markup for a note box. 2021-04-20 15:46:45 -07:00
Tim Kientzle
fbec09bd56 Consolidate format-independent discussion at the end 2021-04-20 15:40:39 -07:00
Tim Kientzle
2a476586d7 Backwards compatibility note 2021-04-20 11:25:03 -07:00
Tim Kientzle
1d5eb5b2be Wordsmithing 2021-04-19 10:30:31 -07:00
Tim Kientzle
0c7f85c56d Feedback 2021-04-19 10:25:09 -07:00
Tim Kientzle
33226b0505 Distinguish "string" (input), "value" or "number" (abstract real number that the string represents), and "instance" (the resulting ${Self}). 2021-04-19 09:09:11 -07:00
Tim Kientzle
b183c7d6c3 present, not future 2021-04-16 16:12:12 -07:00
Tim Kientzle
20ba149dc3 More wordsmithing. 2021-04-16 14:00:11 -07:00
Tim Kientzle
98cec1321d Document how out-of-range inputs are handled
This changed recently so that overflow and underflow consistently return signed
infinity or zero instead of nil.  (Previously, overflow returned nil, underflow
returned zero.)

Among other benefits:
 * The new behavior distinguishes malformed input (nil) from valid but out-of-range input.
 * The new behavior preserves the sign of the input
 * The new behavior is consistent with how floating-point parsing behaves in other langauges

Resolves rdar://76728925
2021-04-16 10:22:59 -07:00
Stephen Canon
95309e1dce Fixup Float16 availability for macCatalyst/x86_64 2020-12-09 13:51:51 -05:00
Stephen Canon
abea46ea59 Make Float16 available for macOS on Apple Silicon (#34821)
Due to an unstable (and undesirable) calling convention in the LLVM layer for x86, I had previously marked Float16 unconditionally unavailable on macOS. My hope was that Intel would stabilize the calling convention and we could make it available on both macOS platforms at the same time. Unfortunately, that hasn't happened, and we want to make the type available for macOS/arm users.

So, I am making the availability mirror Float80--the type will be unavailable for macOS on x86_64, and available on all other platforms (the other x86 platforms don't have a binary-stability guarantee to worry about). This isn't ideal. In particular, if/when the calling conventions for Float16 stabilize in LLVM, we would want to make the type available, but it would then have _different_ availability for different architectures of macOS, which the current availability system is not well-equipped to handle (it's possible, but not very ergonomic). Nonetheless, this seems like the best option.

The good news is that because the full API is already built in Swift (and simply marked unavailable), we can simply add macOS 11.0 availability for these API and it will work.
2020-11-19 09:36:03 -05:00
Alexis Laferrière
a4bf73860b [stdlib] Align availability of a Float16 initializer with its type
The constructor `init?(text: Substring)` was more available than its
type Float16 for macOS and macCatalyst where the type is explicitly
unavailable. The compiler may report this as an error in the future.
2020-09-11 13:32:44 -07:00
Stephen Canon
103961a7d5 Make Float16 unavailable on macOS and macCatalyst, mirroring Xcode's Swift. (#32868)
LLVM doesn't have a stable ABI for Float16 on x86 yet; we're working with Intel to get that fixed, but we don't want to make the type available on macOS until a stable ABI is actually available, because we'd break binaries compiled before any calling convention changes if we do.
2020-07-14 20:42:12 -04:00
Mishal Shah
272c466e47 Update master to build with Xcode 12 beta 2020-06-22 15:43:20 -07:00
Stephen Canon
248c554524 Add Float16 to stdlib (#30130)
Add Float16 (IEEE 754 binary16) to the standard library, plus assorted runtime support operations.

Swift Evolution thread: https://forums.swift.org/t/se-0277-float16/33546
2020-04-06 17:57:44 -04:00
tbkka
4d0e2adbef Further refinement of {Float,Double,Float80}.init(_:String) (#29028)
* Further refinement of {Float,Double,Float80}.init(_:String)

After talking with @stephentyrone, I found some additional simplifications. No
functional change, just shorter/simpler.

This makes the generic inlineable part a small stub that delegates to the full
non-inlined version.

ABI compatibility:
* We support the same generic init() as before
* _swift_stdlib_strtoXYZ_clocale is still available to
  support old inlined code

API addition:
* We now have a public specialized form of init?(_: Substring)
  in addition to the generic init?<S:StringProtocol> form.

* Add @available marker to new API

* Support back-deployment to older OSes by inlining the full version
2020-02-14 16:16:29 -08:00
tbkka
246d52defe Simplify the floating-point parsing initializers (#28992)
The original version scanned the entire input string for whitespace and
non-ASCII characters.  Both are unnecessary: the C routines we're building on
already stop at non-ASCII characters or non-leading whitespace.  So we need only
check the first character for whitespace and verify that all characters are
consumed.

This both improves performance and reduces the amount of code that gets inlined into consumers.
2020-01-06 09:52:21 -08:00
Paul Hudson
06f82a53b5 Replaced the majority of ' : ' with ': '. 2019-07-18 20:46:07 +01:00
Vlad Gorlov
6370681656 Android cross-compile on macOS: Fix for compile error addressed Float80 data type. (#25502)
* Fixes issue addressed Float80 data type. Float80 is disabled for Intel architectures (i.e. Android Simulator).

* More precise condition check.
2019-06-17 13:40:44 -04:00
Thomas Roughton
4c2df287a7 [stdlib] Use String’s underlying UTF-8 view for Float parsing 2019-04-23 10:46:19 +12:00
Karoy Lorentey
5d4ad4a506 [gardening][stdlib] Don't let Emacs modify gyb-generated sources 2018-06-25 17:16:39 +01:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Michael Ilseman
3be2faf5d3 [String] Initial implementation of 64-bit StringGuts.
Include the initial implementation of _StringGuts, a 2-word
replacement for _LegacyStringCore. 64-bit Darwin supported, 32-bit and
Linux support in subsequent commits.
2018-01-21 12:32:26 -08:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Ben Cohen
92bc5b7829 Switch Int/Float inits + join to be on StringProtocol 2017-07-25 08:28:22 -07:00
Robert Widmann
0cf1b52452 Treat Cygwin as a separate OS
Cygwin is considered a distinct target with a distinct ABI, environment
conditions, and data types.  Though the goal of the project is
native Windows integration with UNIX-likes, that is not compatible with
the idea that the platform can be ignored as Win-like enough to have the
existing os(Windows) condition apply.
2017-06-28 13:31:05 -07:00
Han Sangjin
a8dec7fa43 [stdlib] Fixed for Cygwin
- CYGWIN symbol is used to distinguish Cygwin environment from other OS
  and other environment in Windows.
- Added windows and windowsCygnus to OSVersion in StdlibUnittest
2017-01-17 02:31:16 +09:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Nate Cook
bd6025f463 [stdlib] Various documentation fixes
- Fix incorrect type in Float(_:String) examples
- Expand discussions for ExpressibleBy_Literal protocols
- Add notes about non-escaping unsafe pointers from closures
- Add note about isEmpty to Collection.count discussions
- Describe imported `Bool` types
- Clean up some floating point discussions
- Provide some additional operator documentation
- Revise documentation for CVarArg functions
- Fix incorrect Set method parameter descriptions
- Clarify array bridging behavior
- Add collection subscript complexity notes
2016-11-11 11:23:49 -06:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
practicalswift
0661f61578 Use a-vs-an consistently. 2016-08-06 12:41:55 +02:00
Nate Cook
559092bbf2 [stdlib] Revise stdlib documentation comments
- Expand pre-example explanations
- Update documentation for SE-0118
- Removing remaining 'iff' usage
- Revise Array discussion
- Fix formIndex(_:offsetBy) parameter formatting
- Improve index/formIndex(_:offsetBy:(limitedBy:)?) discussion
- Update Quick Look discussions
- Fixes grammar inconsistencies
- Adds parameter / return documentation
- Adds and expands on examples
- Revises AnyObject discussion for new `id` bridging rules
- Revise readLine, print, and assertion functions
- Add missing docs to String index-moving methods
2016-08-05 16:07:46 -05:00
Nate Cook
29c9c61f03 [stdlib] Revise and expand floating-point documentation 2016-07-31 10:14:06 -05:00
Andrew Trick
0b75ee975e Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer

This adds a "mutating" initialize to UnsafePointer to make
Immutable -> Mutable conversions explicit.

These are quick fixes to stdlib, overlays, and test cases that are necessary
in order to remove arbitrary UnsafePointer conversions.

Many cases can be expressed better up by reworking the surrounding
code, but we first need a working starting point.
2016-07-28 20:42:23 -07:00
Robert Widmann
4c2dbe1723 [stdlib][SE-0089] Finish off Lossless String Conversion (#3761)
* Rename string reflection init

* Addressing PR comments and updating some tests

* Update test suite for lossless string conversion
2016-07-28 17:13:25 -07:00
Bob Wilson
58395b3b2f [SE-0127] Add "to:" argument label to withUnsafe[Mutable]Pointer.
rdar://problem/26529498
2016-07-26 17:44:33 -07:00
Dave Abrahams
5a5f19aa45 first/contains(predicate) => first/contains(where: predicate) 2016-07-19 07:12:59 -06:00
Michael Gottesman
fc37603c5f Revert "Implement SE-0118" 2016-07-18 16:44:58 -07:00