Commit Graph

514 Commits

Author SHA1 Message Date
David Smith
f800fdf3d2 Adopt indirect tagged strings (#80425)
Fixes rdar://142991821
2025-04-01 12:53:29 -07:00
Kuba Mracek
6d71f45101 [embedded] Stop using -D__APPLE__ and -D__MACH__ 2025-03-31 15:07:11 -07:00
Alejandro Alonso
4e087653f2 Update Unicode data files in stdlib 2025-01-15 14:07:46 -08:00
Saleem Abdulrasool
edbdd06d71 runtime: silence unhelpful warning
This TODO has existed since the introduction of the Windows platform and
has not been addressed. The implementation at this point is well tested
in practice. Clean up the warning message and style and remove the
warning.
2024-12-13 09:27:41 -08:00
Alastair Houghton
f2e48bd293 Merge pull request #76257 from AreaZR/e
Use instancetype for the benchmark and SwiftNativeNSObject
2024-11-14 14:18:00 +00:00
Ben Barham
684166e24c [embedded] Skip C++ stdlib for unicode stubs
`stdint.h` should be picked up from `clang/lib/Headers`, but is instead
being picked up by the system libc++. There's no C++ stdlib being used
here, so just exclude it.

Resolves rdar://134584685.
2024-09-27 21:19:16 -07:00
Rose
7f2787e249 Use instancetype for the benchmark and SwiftNativeNSObject
This is more for consistency than anything else, really.
2024-09-04 13:07:04 -04:00
Mishal Shah
48d5aca28d Revert "Use associated objects to attach contiguous array buffers to lazy one…"
This reverts commit 7c011813f2.
2024-07-21 23:34:57 -07:00
David Smith
7c011813f2 Use associated objects to attach contiguous array buffers to lazy ones (#75148)
rdar://132124808
2024-07-19 23:21:41 -07:00
Carl Peto
3689427834 [AVR] standard library support for AVR
- when compiling embedded cross compile target standard libraries, include AVR
- add 16-bit pointer as a conditional compilation condition and get the void pointer size right for gyb sources
- attempt to fix clang importer not importing __swift_intptr_t correctly on 16 bit platforms
- changed the unit test target to avr-none-none-elf to match the cmake build

[AVR] got the standard library compiling in a somewhat restricted form:

General
- updated the Embedded Runtime
- tweaked CTypes.swift to fix clang import on 16 bit platforms

Strings
- as discussed in https://forums.swift.org/t/stringguts-stringobject-internals-how-to-layout-on-16-bit-platforms/73130, I went for just using the same basic layout in 16 bit as 32 bit but with 16 bit pointers/ints... the conversation is ongoing, I think something more efficient is possible but at least this compiles and will probably work (inefficiently)

Unicode
- the huge arrays of unicode stuff in UnicodeStubs would not compile, so I skipped it for AVR for now.

Synchronization
- disabled building the Synchronization library on AVR for now. It's arguable if it adds value on this platform anyway.
2024-07-16 12:28:27 +01:00
Alexander Cyon
c21b1e68fd [stdlib] Fix typos 2024-07-06 13:09:57 +02:00
Kuba Mracek
6eeef12849 [embedded] Add a embedded-libraries CMake target to simplify the test dependencies 2024-06-23 13:08:01 -07:00
Eric Miotto
66df28f108 [embedded] use dedicated CMakeLists.txt to build unicode data tables
This will avoid CMake configuration errors in `llvm_process_sources`
 in configurations that build only the the standard library for embedded.

Addresses rdar://130229502
2024-06-20 14:04:28 -07:00
Kuba Mracek
5ec41ad232 [embedded] Use -ffreestanding when building Unicode data tables library even on Linux 2024-05-27 13:07:28 -07:00
Kuba Mracek
78d19ff6ba [embedded] Explicitly install libswiftUnicodeDataTables.a with -x permissions 2024-05-26 13:00:53 -07:00
Kuba Mracek
7d92baaddd [embedded] Provide Unicode data tables for embedded as a static library 2024-05-26 13:00:52 -07:00
David Smith
b81aec5c1a rdar://127199021, fix compatibility with apps that accidentally do [[[aSwiftArray class] new] mutableCopy] to work (#73728) 2024-05-20 12:06:05 -07:00
Yuta Saito
c32c7f55fe [wasm] Fix build failure due to lack of _Float16 support
WebAssembly does not support _Float16 type, so we need to guard the use
of the type. Unfortunately, Clang does not provide a good way to detect
the support of _Float16 type at compile time, so just disable for wasm
targets.
2024-04-07 16:34:11 +00:00
Stephen Canon
6ac852f3f4 Move Float16 print tests to their own file and test exhaustively (#72859)
We can easily test all 2**16 values, so let's do it. Also now _Float16 is properly supported in clang, so we can pass arguments to CPP that way, which lets us get snan right on more platforms.
2024-04-05 19:55:19 -04:00
Alastair Houghton
b2509d9306 [Runtime] Don't use <sys/errno.h>.
We should always be using `<errno.h>`, not `<sys/errno.h>`.  The
former is part of the C standard.  The latter is a non-standard
header that happens to be present on some systems.

rdar://123507361
2024-02-23 16:02:31 +00:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
David Smith
f1feba0e42 Eytzingerize word break data (#71731)
Switch word break property searching to Eytzinger binary search
2024-02-20 22:49:34 -08:00
David Smith
ea7d07714f Switch grapheme break property searching to Eytzinger binary search (#71668) 2024-02-16 16:06:20 -08:00
Erik Eckstein
e4ea7491a2 IRGen: fix and re-enable static read-only arrays
Static read-only arrays didn't work when passed to ObjectiveC as NSArray.
The storage class of static read-only arrays doesn't carry information about the Element type.
The new `__SwiftDeferredStaticNSArray` is generic over the element type and doesn't have to rely on the element type information of the array storage.

rdar://94185998
2023-12-13 11:45:01 +01:00
Yuta Saito
68bc510e73 [wasm][stdlib] Don't include <thread> with swift-threading-package=none
We can't assume libcxx to be built with `LIBCXX_ENABLE_THREADS=YES` with
none threading package.
2023-10-06 00:51:33 +00:00
Saleem Abdulrasool
2349a4fb9d Update LibcShims.cpp
Add missing include for `atexit`.
2023-09-06 19:37:50 -07:00
YR Chen
e39babe1c9 Fix building LibcShims.cpp with MSVC v14.37
`_swift_stdlib_configure_console_mode` reverts console codepage on Windows using `atexit`, which is declared in `stdlib.h`.

Add the missing `#include <stdlib.h>` to unblock building Swift `stdlib` with MSVC v14.37 (Visual Studio 17.7).
2023-08-09 17:32:07 +08:00
David Smith
e20be0edc6 Revert [Runtime] Let CF provide us with state, avoiding runtime lookup. rdar://111104451 (#66606) 2023-06-22 10:24:51 -07:00
David Smith
300f3fd12f Better memory order 2023-06-21 11:08:34 -07:00
David Smith
bb394a0561 Use proper atomics instead of trying to do it with explicit barriers 2023-06-21 10:58:56 -07:00
David Smith
53d308afcf Add an explicit barrier, mostly for clarity 2023-06-21 10:42:28 -07:00
David Smith
1d3ee23387 Use swift::once instead of swift_once to clean up the code a little, and make sure we unconditionally set the state from CF to make sure it's set even if we failed a lazy load earlier
(cherry picked from commit 1394a8e3ab529e855a5940ad983dacf402d09550)
2023-06-21 10:21:27 -07:00
David Smith
7eb8283a49 [Runtime] Let CF provide us with state, avoiding runtime lookup. rdar://111104451 (#66606)
Provide a hook for CF to tell us about the state we need from it, rather than us having to look it up at runtime
2023-06-21 08:38:14 -07:00
Alejandro Alonso
04f6e1ad7c Add some more documentation around the scalar arrays 2023-03-30 15:01:12 -07:00
Alejandro Alonso
ade2b754cc Fix Common normData prefix 2023-03-29 13:32:43 -07:00
Alejandro Alonso
cc62bb1ddc Update copyright years 2023-03-29 10:35:30 -07:00
Alejandro Alonso
f16f0c3c23 Update the stdlib to use Unicode 15 data 2023-03-29 10:18:16 -07:00
Jonathan Grynspan
0368538ec5 Loop on Win32 to satisfy large random byte requests (as is done on Linux) (#62364) 2022-12-05 18:14:57 -05:00
Alsey Coleman Miller
62b7be4e9c [stdlib] Add RISCV64 support 2022-11-01 23:59:42 -07:00
Robert Widmann
9159f8772d Merge pull request #61322 from CodaFi/whats-in-a-name
Work Around _swiftStaticArrayMetadata Alias Breakage
2022-09-27 19:50:12 -07:00
Robert Widmann
ba3e67bd03 Work Around _swiftStaticArrayMetadata Alias Breakage
The alias defined here with the `.set` directive doesn't actually define a symbolic alias
that the linker respects in all cases. The resulting standard library dylib _does_ contain a
reference to the aliased symbol with the correct value, but the resulting variable is not actually
considered relocatable by the linker. Thus, its value may not always get fixed up properly.

Work around this by dropping the alias for now - directly use the type metadata for Swift.__EmptyArrayStorage
instead.

rdar://100288247
2022-09-27 13:58:18 -07:00
Anthony Latsis
c731089068 Gardening: Migrate stdlib sources to GH issues 2022-09-26 06:30:49 +03:00
Egor Zhdan
84a1ffcb33 [Shims] Include SwiftShims headers without ../
This replaces a number of `#include`-s like this:
```
#include "../../../stdlib/public/SwiftShims/Visibility.h"
```
with this:
```
#include "swift/shims/Visibility.h"
```

This is needed to allow SwiftCompilerSources to use C++ headers which include SwiftShims headers. Currently trying to do that results in errors:
```
swift/swift/include/swift/Demangling/../../../stdlib/public/SwiftShims/module.modulemap:1:8: error: redefinition of module 'SwiftShims'
module SwiftShims {
       ^
Builds.noindex/swift/swift/bootstrapping0/lib/swift/shims/module.modulemap:1:8: note: previously defined here
module SwiftShims {
       ^
```
This happens because the headers in both the source dir and the build dir refer to SwiftShims headers by relative path, and both the source root and the build root contain SwiftShims headers (which are equivalent, but since they are located in different dirs, Clang treats them as different modules).
2022-09-14 11:14:50 +01:00
Alejandro Alonso
95da55b182 [stdlib] Implement String.WordView (#42414)
* Implement String.WordView

* Add isWordAligned bit

* Hide WordView for now (also separate Index type)

add bidirectional conformance

Fix tests

* Address comments from Karoy and Michael

* Remove word view, use index methods

* Address Karoy's comments

aaa
2022-06-22 09:10:09 -07:00
Erik Eckstein
9d61e210ec runtime: export two symbols used to create static constant arrays.
* `__swiftImmortalRefCount`: The bit pattern of the ref-count field of immortal objects
* `__swiftStaticArrayMetadata`: The metadata used for static arrays.
2022-06-17 11:21:29 +02:00
Yuta Saito
b3007e5523 [stubs] include unistd.h to repair swift-threading-package=none build
`syscall` and `read` were missing when `swift-threading-package=none`
2022-06-10 14:09:07 +00:00
Alastair Houghton
c401cc34fd [Threading] Use llvm::Optional<> rather than making a zero lower bound special.
While most systems aren't going to have their stack bottom at zero,
using llvm::Optional<> here is cleaner.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
b5c8b79556 [Threading] Move stack bounds fetching into the threading library.
Fetching the current stack bounds is done using threading functions, so
should be in the threading library.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
eb4c81d60e [Threading] Don't use TLS keys as template arguments.
There's no guarantee that e.g. pthread_key_t is an integral type.  It could
be some kind of struct, or some other thing that isn't valid as a template
argument.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
c7c1c1be80 [Threading] Fix some problems with the C11 threading code.
These changes are needed to get things building with a C11 threads shim
header on macOS.

rdar://90776105
2022-06-07 07:39:53 +01:00