Commit Graph

26 Commits

Author SHA1 Message Date
Allan Shortlidge
682e10457f Tests: Suppress a warning about an unused variable. 2024-11-13 09:51:29 -08:00
Rintaro Ishizaki
9c9010e5b7 [CMake] Support Macros in Linux
For compiling codes required for macro support, we now need swiftc
compiler in the build machine.

Unlike Darwin OSes, where swiftCore runtime is guaranteed to be present
in /usr/lib, Linux doesn't have ABI stability and the stdlib of the
build machine is not at the specific location. So the built compiler
cannot relies on the shared object in the toolchain.
2023-08-24 17:04:15 +00:00
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02:00
Alastair Houghton
d092d4bb66 [Threading][Tests] Don't test timeouts on threading=none.
The preprocessor condition stopping tests from running for threading=none
was in slightly the wrong place.

rdar://100707643
2022-10-03 09:26:25 +01:00
Alastair Houghton
d0f42cad11 [Threading][Win32] Fix the wait functions for Win32 to always over-wait.
Rather than bodging the test to make it more robust, fix the functions
in the Threading layer to behave the same as they do on other platforms,
i.e. to guarantee that they always wait *at least* the amount of time
you asked for.

rdar://100236038
2022-09-29 17:01:59 +01:00
Alastair Houghton
10ab608707 [UnitTests][Threading] Tweak ConditionVariable test for Windows.
Windows' behaviour wrt `Sleep` family functions can be odd.  Apparently,
if you specify a time lower than a system tick, they can return early.
This makes the test flaky when it shouldn't be.  To fix it, we use the
Multimedia functions to adjust the system tick count as low as we can
get it.

rdar://100236038
2022-09-29 15:41:38 +01:00
Alastair Houghton
4495d63c12 [Threading] Add ConditionVariable support.
Swift Concurrency would like to be able to use condition variables.
Add support to the threading packages.

rdar://100236038
2022-09-27 16:21:13 +01:00
Yuta Saito
356156dfb9 [Threading][unittest] skip try_lock checks under none threading 2022-07-07 01:57:38 +00:00
Alastair Houghton
14e01b015a [Threading][UnitTests] Don't use threads in the unit test in no-threads mode.
If the threading package is set to "none", don't actually use threads in the
unit tests.

rdar://95011060
2022-07-07 01:57:38 +00:00
Alastair Houghton
6962758c8c [Threading] Add the ability to use any C++ callable in swift::once().
This allows the use of C++ lambdas and functors, in addition to plain
old functions.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
0e9318cec5 [Threading] Put everything through git clang-format.
Just formatting changes.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
210b772800 [UnitTests][Windows] Link with Synchronization.lib
The runtime unit tests also need to link with Synchronization.lib.

rdar://90776105
2022-06-07 07:39:53 +01:00
Alastair Houghton
3bfc7e0731 [Threading][Windows] Link the unit test against Synchronization.lib
We need to link the threading unit test against Synchronization.lib
to pick up the Win32 APIs we're using.

rdar://90776105
2022-06-07 07:39:52 +01:00
Alastair Houghton
6d1b6dbd1c [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-06-07 07:39:52 +01:00
Alastair Houghton
785f4a215c [Unittests] Add more threading library tests.
Added explicit tests for `swift::once` and also for the ulock implementation
used on Linux.

rdar://90776105
2022-06-07 07:39:51 +01:00
Alastair Houghton
2ba80e1180 [Unittests] Make the Threading unit tests work.
The threading unit tests currently just check the operation of Mutex.
This used to be part of the runtime tests, but now it's a separate
library we can test it separately.

rdar://90776105
2022-06-07 07:39:51 +01:00
Alastair Houghton
f5bdb858e0 [Threading] Create new threading library and use it.
Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
2022-06-07 07:39:51 +01:00
Alex Hoppen
4aa2bbbf06 Revert "Merge pull request #42447 from al45tair/eng/PR-90776105"
This reverts commit 8bcb71140f, reversing
changes made to c4dd271d36.
2022-06-02 18:03:23 +02:00
Alastair Houghton
901ceaef13 [Threading] Add the ability to use any C++ callable in swift::once().
This allows the use of C++ lambdas and functors, in addition to plain
old functions.

rdar://90776105
2022-05-24 14:57:42 +01:00
Alastair Houghton
b5bd267ff1 [Threading] Put everything through git clang-format.
Just formatting changes.

rdar://90776105
2022-05-24 14:57:41 +01:00
Alastair Houghton
dadd23e5e2 [UnitTests][Windows] Link with Synchronization.lib
The runtime unit tests also need to link with Synchronization.lib.

rdar://90776105
2022-05-24 14:57:41 +01:00
Alastair Houghton
d5c022f628 [Threading][Windows] Link the unit test against Synchronization.lib
We need to link the threading unit test against Synchronization.lib
to pick up the Win32 APIs we're using.

rdar://90776105
2022-05-24 14:57:41 +01:00
Alastair Houghton
fc90280e34 [Threading] Fix the Linux build.
A few fixes specifically for the Linux build.

rdar://90776105
2022-05-24 14:57:39 +01:00
Alastair Houghton
4280222286 [Unittests] Add more threading library tests.
Added explicit tests for `swift::once` and also for the ulock implementation
used on Linux.

rdar://90776105
2022-05-24 14:57:39 +01:00
Alastair Houghton
ddea8b18a8 [Unittests] Make the Threading unit tests work.
The threading unit tests currently just check the operation of Mutex.
This used to be part of the runtime tests, but now it's a separate
library we can test it separately.

rdar://90776105
2022-05-24 14:57:39 +01:00
Alastair Houghton
63a09007a1 [Threading] Create new threading library and use it.
Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
2022-05-24 14:57:39 +01:00