File tree Expand file tree Collapse file tree 2 files changed +54
-7
lines changed Expand file tree Collapse file tree 2 files changed +54
-7
lines changed Original file line number Diff line number Diff line change @@ -3213,13 +3213,14 @@ namespace {
3213
3213
d->getName () == " cos" || d->getName () == " exit" ;
3214
3214
return false ;
3215
3215
};
3216
- if (decl->getOwningModule () &&
3217
- (decl->getOwningModule ()
3218
- ->getTopLevelModule ()
3219
- ->getFullModuleName () == " std" ||
3220
- decl->getOwningModule ()
3221
- ->getTopLevelModule ()
3222
- ->getFullModuleName () == " _SwiftConcurrencyShims" )) {
3216
+ auto topLevelModuleEq =
3217
+ [](const clang::FunctionDecl *d, StringRef n) -> bool {
3218
+ return d->getOwningModule () &&
3219
+ d->getOwningModule ()
3220
+ ->getTopLevelModule ()
3221
+ ->getFullModuleName () == n;
3222
+ };
3223
+ if (topLevelModuleEq (decl, " std" )) {
3223
3224
if (isAlternativeCStdlibFunctionFromTextualHeader (decl)) {
3224
3225
return nullptr ;
3225
3226
}
@@ -3231,6 +3232,13 @@ namespace {
3231
3232
return nullptr ;
3232
3233
}
3233
3234
}
3235
+ // Use the exit function from _SwiftConcurrency.h as it is platform
3236
+ // agnostic.
3237
+ if ((topLevelModuleEq (decl, " Darwin" ) ||
3238
+ topLevelModuleEq (decl, " SwiftGlibc" )) &&
3239
+ decl->getDeclName ().isIdentifier () && decl->getName () == " exit" ) {
3240
+ return nullptr ;
3241
+ }
3234
3242
}
3235
3243
3236
3244
auto dc =
Original file line number Diff line number Diff line change
1
+ // RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xfrontend -disable-availability-checking %import-libdispatch -parse-as-library)
2
+ //
3
+ // REQUIRES: executable_test
4
+ // REQUIRES: concurrency
5
+ // REQUIRES: libdispatch
6
+ // REQUIRES: concurrency_runtime
7
+
8
+ import StdlibUnittest
9
+
10
+ import CxxStdlib
11
+ import Cxx
12
+
13
+ import _Concurrency
14
+ import Dispatch
15
+
16
+ @main struct Main {
17
+ static func main( ) async {
18
+ var ConcurrencyTestSuite = TestSuite ( " Concurrency " )
19
+
20
+ ConcurrencyTestSuite . test ( " Task.sleep " ) {
21
+ let start = DispatchTime . now ( )
22
+ await Task . sleep ( 100_000_000 )
23
+ let stop = DispatchTime . now ( )
24
+ expectTrue ( stop >= ( start + . nanoseconds( 100_000_000 ) ) )
25
+ }
26
+
27
+ ConcurrencyTestSuite . test ( " Task.sleep (non-blocking) " ) {
28
+ let task = detach {
29
+ std. string ( " Hello, Swift! " )
30
+ }
31
+
32
+ await Task . sleep ( 100_000_000 )
33
+ expectEqual ( await task. get ( ) , " Hello, Swift! " )
34
+ }
35
+
36
+ await runAllTestsAsync ( )
37
+ }
38
+ }
39
+
You can’t perform that action at this time.
0 commit comments