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 @@ -3210,13 +3210,14 @@ namespace {
3210
3210
d->getName () == " cos" || d->getName () == " exit" ;
3211
3211
return false ;
3212
3212
};
3213
- if (decl->getOwningModule () &&
3214
- (decl->getOwningModule ()
3215
- ->getTopLevelModule ()
3216
- ->getFullModuleName () == " std" ||
3217
- decl->getOwningModule ()
3218
- ->getTopLevelModule ()
3219
- ->getFullModuleName () == " _SwiftConcurrencyShims" )) {
3213
+ auto topLevelModuleEq =
3214
+ [](const clang::FunctionDecl *d, StringRef n) -> bool {
3215
+ return d->getOwningModule () &&
3216
+ d->getOwningModule ()
3217
+ ->getTopLevelModule ()
3218
+ ->getFullModuleName () == n;
3219
+ };
3220
+ if (topLevelModuleEq (decl, " std" )) {
3220
3221
if (isAlternativeCStdlibFunctionFromTextualHeader (decl)) {
3221
3222
return nullptr ;
3222
3223
}
@@ -3228,6 +3229,13 @@ namespace {
3228
3229
return nullptr ;
3229
3230
}
3230
3231
}
3232
+ // Use the exit function from _SwiftConcurrency.h as it is platform
3233
+ // agnostic.
3234
+ if ((topLevelModuleEq (decl, " Darwin" ) ||
3235
+ topLevelModuleEq (decl, " SwiftGlibc" )) &&
3236
+ decl->getDeclName ().isIdentifier () && decl->getName () == " exit" ) {
3237
+ return nullptr ;
3238
+ }
3231
3239
}
3232
3240
3233
3241
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