Commit Graph

9 Commits

Author SHA1 Message Date
Saleem Abdulrasool
ca39bb5b10 stubs: avoid reaching up-tree, prefer inclusion options
This removes the explicit tree structure reference in the stubs to
locate the shims.  Instead, it expects that the `SwiftShims` directory
will be added to the header search path.
2022-01-14 09:34:56 -08:00
Mike Ash
190d3fd22e [Concurrency] Use pthread_specific for thread-local storage on Darwin.
The pthread_specific APIs are better than C++ thread_local storage on Darwin since we can use Swift's reserved pthread keys there.

rdar://79504652
2021-06-29 16:56:59 -04:00
Kuba (Brecka) Mracek
9ead8d57fa Add a single-threaded stdlib mode, use it for the 'minimal' stdlib (#33437) 2020-08-25 06:03:14 -07:00
Saleem Abdulrasool
64ed0a4077 stdlib: silence a unused function warning (NFC)
Pre-process away the unused function on Darwin.  NFC.
2019-09-20 17:34:17 -07:00
Saleem Abdulrasool
cc9a567ec7 stdlib: use the destructor CC adjustment thunk
Use the wrapper for the CC adjustment as on Windows x86, the destructor
needs to be `__stdcall`.  This would fail otherwise with the following:

```
D:\a\1\s\swift\stdlib\public\stubs\ThreadLocalStorage.cpp(86,18):  error: no matching function for call to '_stdlib_thread_key_create'
    int result = SWIFT_THREAD_KEY_CREATE(&key, [](void *pointer) {
                 ^~~~~~~~~~~~~~~~~~~~~~~
D:\a\1\s\swift\stdlib\public\stubs/../runtime/ThreadLocalStorage.h(96,35):  note: expanded from macro 'SWIFT_THREAD_KEY_CREATE'
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~
D:\a\1\s\swift\include\swift/Basic/Lazy.h(42,27):  note: expanded from macro 'SWIFT_ONCE_F'
  ::std::call_once(TOKEN, FUNC, CONTEXT)
                          ^~~~
D:\a\1\s\swift\stdlib\public\stubs\ThreadLocalStorage.cpp(43,1):  note: candidate function not viable: no known conversion from '(lambda at D:\a\1\s\swift\stdlib\public\stubs\ThreadLocalStorage.cpp:85:3)' to '__swift_thread_key_destructor _Nullable' (aka 'void (*)(void *) __attribute__((stdcall))') for 2nd argument
_stdlib_thread_key_create(__swift_thread_key_t * _Nonnull key,
^

```
2019-08-20 19:11:46 -07:00
Saleem Abdulrasool
40da65a43f runtime: correct _stdlib_thread_key_create
The mapping of the return value of the `FlsAlloc` was flipped resulting
in the failure of the TLS key creation.  The test suite would fail to
generate the TLS key resulting in failures.
2018-12-23 10:02:49 -08: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
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
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