Commit Graph

515 Commits

Author SHA1 Message Date
Mike Ash
45693049bf [Stdlib] Remove SwiftPrivate's dependency on Darwin.
Revert #20194, which seems to be more trouble than it's worth. Instead, move the functions that SwiftPrivate needs back into LibcShims.h/cpp as SPI.

rdar://problem/45817565
2018-11-06 17:41:56 -05:00
Michael Ilseman
948655e850 [String] Cleanups, comments, documentation
After rebasing on master and incorporating more 32-bit support,
perform a bunch of cleanup, documentation updates, comments, move code
back to String declaration, etc.
2018-11-04 10:42:42 -08:00
Michael Gottesman
3f17bb6ddf Carefully split the build's invocation of add_swift_library into host/target variants.
The key thing here is that all of the underlying code is exactly the same. I
purposely did not debride anything. This is to ensure that I am not touching too
much and increasing the probability of weird errors from occurring. Thus the
exact same code should be executed... just the routing changed.
2018-10-27 12:58:51 -07:00
Saleem Abdulrasool
92ef7e46dc stdlib: use some clever C11 to define ssize_t
`ssize_t` is not universally available as it is not a standard type.
However, we require clang to build the runtime due to custom calling
convention support.  As a result, we know that the compiler will support
the `_Generic` keyword from the C11 standard.  Use this with an
expansion to map the type appropriately for all targets.  This avoids
having to have a sanity check in the runtime that the type definition
matches the underlying system.
2018-10-08 11:49:02 -07:00
Saleem Abdulrasool
68ec9d4a0f stdlib: correct case for the bcrypt import library
On Windows the filesystem is not case sensitive and this will link just fine.
However, the Windows SDK provides the import library with the lowercase name.
Adjust the name so that the link actually succeeds on case-sensitive file
systems (like on Linux).  This fixes the Windows cross-compile.
2018-10-05 11:21:20 -07:00
Saleem Abdulrasool
6729aacaef stdlib: include "Windows.h" before "Bcrypt.h"
The system header depends on Windows.h but does not include it itself.  This
results in base Windows types (e.g. ULONG) to be undefined.  Include the header
to include the needed typedefs.
2018-10-05 11:20:23 -07:00
Mike Ash
1e9741a3f8 [Stdlib] Fix Linux detection for malloc_size. Silence const cast warnings. Fix Linux implementation in Random.cpp to actually compile. 2018-10-03 14:31:39 -04:00
Mike Ash
5391abbf4b [Stdlib] Clean up includes in LibcShims and Random. 2018-10-03 11:16:37 -04:00
Mike Ash
c4d5db404b [Stdlib] Change _swift_stdlib_random SPI to swift_stdlib_random API. 2018-10-03 09:55:34 -04:00
Mike Ash
5f17b450c3 [Stdlib] Make all the functions in LibcShims.h either INTERNAL or inline. Move LibcShimsInline.h to LibcOverlayShims.h for more consistent naming. Fix up several tests that needed the mock Darwin overlay built. Fix one SourceKit test that no longer produces is_system: 1 on an import Darwin line. 2018-10-03 09:55:34 -04:00
Mike Ash
ec25f928ff [Stdlib] Move _swift_stdlib_read/write/close into LibcShimsInline.h. 2018-10-03 09:55:34 -04:00
Mike Ash
b2675280c7 [Stdlib] Move the shims used by Platform.swift into a separate header and make them static inline. This avoids exposing them as exported symbols in libswiftCore. 2018-10-03 09:55:34 -04:00
Mike Ash
6926fbd363 [Stdlib] Pull _swift_stdlib_random into a separate file. 2018-10-03 09:55:34 -04:00
Mike Ash
e18e03171f [Stdlib] Change SWIFT_RUNTIME_STDLIB_INTERNAL to not export the symbol.
The functions in LibcShims are used externally, some directly and some through @inlineable functions. These are changed to SWIFT_RUNTIME_STDLIB_SPI to better match their actual usage. Their names are also changed to add "_swift" to the front to match our naming conventions.

Three functions from SwiftObject.mm are changed to SPI and get a _swift prefix.

A few other support functions are also changed to SPI. They already had a prefix and look like they were meant to be SPI anyway. It was just hard to notice any mixup when they were #defined to the same thing.

rdar://problem/35863717
2018-10-03 09:55:33 -04:00
Jordan Rose
c3b1143b15 Merge pull request #19607 from Kaiede/debianHost
Enable i686 as a Host Platform
2018-10-02 16:24:58 -07:00
Adam Thayer
eddecbfcd4 [i686 Linux] Add __mulodi4 Math Stub to i686
Win and Linux Arm32 have the same aversion to linking compiler-rt for this.
2018-09-28 10:14:44 -07:00
Karoy Lorentey
911d4ab5a4 [runtime] Update empty singletons for Set/Dictionary
Also add static_assert for Set/Dictionary storage header size.
2018-09-27 01:49:50 +01:00
Alejandro
054adb3b3e [Stubs] _stdlib_random: Try to use direct syscall to getrandom (#19309)
Instead of only requiring Glibc's implementation of getrandom, try to use a direct syscall to getrandom. This should allow more versions of linux to utilize getrandom instead of always having to fallback to reading /dev/urandom.
2018-09-25 09:55:19 -04:00
Karoy Lorentey
6cef0beff9 Merge pull request #19495 from lorentey/simplify-rawHashValue
[stdlib] Finalize one-shot hashing interface
2018-09-24 21:44:36 +01:00
Mike Ash
1fb165a0ea Merge branch 'master' into rename-conflicting-classes-and-methods 2018-09-24 10:17:22 -04:00
Karoy Lorentey
6d81663716 [stdlib] Make Hashable._rawHashValue(seed:) safer and more convenient
- Don’t expose the raw execution seed to _rawHashValue.
- Change the type of _rawHashValue’s seed from (UInt64,UInt64) to a single Int. Working with a pair of UInt64s is unwieldy, and overkill in practice. Int as a seed also integrates nicely with Int as a hash value.
- Remove _HasherCore._generateSeed(). Instead, simply call finalize() on a copy of the hasher to get a seed suitable for _rawHashValue.
- Update Set and Dictionary to store a single Int as the seed value.

Note that this doesn’t affect the core hasher, which still mixes in the actual 128-bit execution seed during its initialization. To reduce the potential of confusion, use the name “rawSeed” to refer to an actual 128-bit seed value.
2018-09-24 13:30:05 +01:00
Karoy Lorentey
ca4898fbbf Merge pull request #19213 from lorentey/hashtable-unification
[stdlib] Set, Dictionary: Hash table unification, general cleanup before ABI stability
2018-09-24 11:20:49 +01:00
Saleem Abdulrasool
c3d5c3d75b stdlib: fix THreadLocalStorage builds for Windows
Due to the build ordering, I didn't notice this earlier.  The inclusion
of the header would define the guard, preventing the needed definitions.
Unconditionally define the functions to ensure that they are available.
2018-09-22 09:32:33 -07:00
Karoy Lorentey
ace19fd106 [runtime] Fix layout of empty Set/Dictionary singletons 2018-09-22 02:04:11 +01:00
Karoy Lorentey
098275f3c7 [stdlib] Clean up Set and Dictionary
- Use _HashTable to unify low-level hashing operations across Set and Dictionary.
- Store the capacity directly inside the storage header. This allows the maximum load factor to be controlled by non-inlinable code.
- Introduce a dedicated class for the empty singleton.
- Add _BridgingHashBuffer, a standalone flat hash buffer for use in deferred bridging. Use it to eliminate the need to support non-hashable storage/wrapper variants and to improve memory use in cases where Key or Value are verbatim bridged.
- Eliminate the “TypedNative*Storage” class and _NativeSet/_NativeDictionary’s support for non-hashable keys.
- Rename storage classes as follows:

_RawNativeSetStorage ⟹ _RawSetStorage
_RawNativeDictionaryStorage ⟹ _RawDictionaryStorage
_TypedNativeSetStorage ⟹ (removed)
_TypedNativeDictionaryStorage ⟹ (removed)
_HashableTypedNativeSetStorage ⟹ _SetStorage
_HashableTypedNativeDictionaryStorage ⟹ _DictionaryStorage

The new names make it obvious which ivar layout is in use.
2018-09-22 02:04:07 +01:00
Karoy Lorentey
edb8a73203 [stdlib] Set, Dictionary: New storage classes for the empty singletons
This allows us to move the empty NSSet/NSDictionary overrides out of the root storage class; they don’t really belong there. More importantly, it makes empty sets/dictionaries super obvious to lldb and other runtime tools.
2018-09-22 02:04:05 +01:00
Mike Ash
49c3547449 Merge remote-tracking branch 'origin/master' into rename-conflicting-classes-and-methods 2018-09-21 15:52:38 -04:00
Saleem Abdulrasool
2d04b8491b stdlib: check for ARM/ARM64 more thoroughly (NFC)
Update the instances of checks for architectures to be more broad for different
spellings of the architecture macro.  Certain targets use `_M_ARM` and others
use `__arm__`.  Similarly, arm64/aarch64 has `_M_ARM64`, `__arm64__` and
`__aarch64__` as spellings.  This just mechanically goes through and encodes the
various spellings.

Take the opportunity to replace some raw checks with `defined` checks which
avoids a pedantic warning due to the undefined macro when performing the check
as the preprocessor may warn about an undefined condition evaluating to `0`.
2018-09-21 11:24:03 -07:00
Mike Ash
317451c8ee [Runtime][Stdlib][Overlays] Add comments to all the renamed classes explaining the rename and noting that the old name cannot be used due to conflicts.
rdar://problem/35768222
2018-09-20 12:07:30 -04:00
Saleem Abdulrasool
1b47910cd9 stdlib: repair the Windows runtime build
Fix syntactic issues in the swift runtime build from the recent TLS changes.
Move the helper definitions into the TLS stubs rather than emitting them
everywhere.  This allows the runtime to build again on Windows.
2018-09-14 11:12:57 -07:00
Mike Ash
798edb9d0e [Runtime][Stdlib][Overlays] Rename various Objective-C classes and methods that would conflict when loading old Swift libraries into a process alongside ABI-stable libraries.
rdar://problem/35768222
2018-09-13 16:55:10 -04:00
Mike Ash
29ff3de4ab [Runtime][Stdlib] Use dedicated thread-local storage keys when possible.
rdar://problem/32275323 rdar://problem/44104305
2018-09-13 14:36:57 -04:00
Mike Ash
8670d663a8 [Stdlib] Update the declaration of llvm::fixed_seed_override to uint64_t to match the change in LLVM commit 4b757883e611d95d4580cd21fd6fb78471f4936e. 2018-08-31 11:24:39 -04:00
Ben Rimmington
2f326bcc88 [stdlib] Remove theGlobalMT19937
SwiftPrivate/PRNG.swift:

- currently uses `theGlobalMT19937`;
- previously used `arc4random` (see #1939);
- is obsoleted by SE-0202: Random Unification.
2018-08-01 13:00:16 +01:00
Jordan Rose
53ff023c6c [Runtime] Print fatal errors' messages before pausing in the debugger (#18374)
The message is available in the debugger (or in Xcode), but it
increases the chances that the user will see it if it's also been
logged at the time the debugger takes over.
2018-07-31 14:40:10 -07:00
Susan Cheng
9b61888046 getrandom introduced in Android API 28 2018-07-31 10:42:10 +08:00
Azoy
b8fc8b333c Remove _interface 2018-07-29 10:41:22 -04:00
Michael Ilseman
30450671fa Merge pull request #15593 from allevato/unicode-properties
[SE-0211] Add Unicode properties to Unicode.Scalar
2018-07-11 13:27:31 -07:00
Michael Ilseman
88fb124643 Merge pull request #17835 from milseman/nfc
[stdlib] Some stubs and trivial refactorings; NFC
2018-07-10 15:10:22 -07:00
Lance Parker
af68a30438 Merge pull request #17846 from lancep/deprecated_simulator_macro
[stdlib]Remove deprecated TARGET_IPHONE_SIMULATOR reference
2018-07-10 13:49:48 -07:00
Lance Parker
b3a08414f7 TARGET_IPHONE_SIMULATOR -> TARGET_OS_SIMULATOR 2018-07-09 14:53:31 -07:00
Michael Ilseman
5358401d35 [string] Add UText shims; NFC
Add ICU shims for creating UTexts and performing grapheme breaking
using UTexts. This will allow us to explore multi-encoding grapheme
support throughout string.
2018-07-09 10:47:37 -07:00
Michael Gottesman
5648ef219d [+0-all-args] Clean up remains of +1 convention from the runtime. 2018-07-06 23:10:12 -07:00
Tony Allevato
d0e93acb00 Various fixes to Unicode.Scalar.Properties.
- numericValue returns nil instead of .nan for non-numerics
- Remove small-string optimizations from _scalarName that failed on 32-bit archs
- Put case mappings back into U.S.Properties
- Added more sanity tests
2018-07-05 20:42:56 -07:00
Tony Allevato
8eef50f6a9 Merge branch 'master' into unicode-properties 2018-07-04 08:42:35 -07:00
David Zarzycki
cc7123dbbf [stdlib] NFC: Remove non-Apple dead code
This code is dead due to: cbf157f924
2018-07-03 14:01:16 -04:00
Nate Cook
7a4e0a32f6 [stdlib] Revise documentation
This includes various revisions to the APIs landing in Swift 4.2, including:
- Random and other randomness APIs
- Hashable changes
- MemoryLayout.offset(of:)
2018-05-18 11:31:54 -05:00
Ben Rimmington
8e6c9ffdba [runtime] Update initializeHashingParameters()
Using `swift::_stdlib_random` instead of `arc4random_buf` or `std::mt19937_64`, etc.
2018-05-14 14:32:46 +01:00
Mike Ash
0a6ea9733c Merge pull request #16281 from mikeash/warning-fix-libcshims-metadata
[Runtime] Fix warnings for inconsistent nullability annotation on _stdlib_getEnviron.
2018-05-10 16:13:02 -04:00
Mike Ash
022253e1e5 [Runtime] Fix warnings for inconsistent nullability annotation on _stdlib_getEnviron.
rdar://problem/39739801
2018-05-09 13:41:58 -04:00