Skip to content

Commit

Permalink
Build on Windows
Browse files Browse the repository at this point in the history
Windows doesn't have dlsym. Since I don't have a Windows box, I'm just
if-def'ing it out for the time being. Since we don't want Windows going
off and doing dangerous things, I threw in an abort just to be safe.
  • Loading branch information
etcwilde committed Jan 14, 2021
1 parent 81ae9d6 commit 13cc56b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions stdlib/public/Concurrency/Task.cpp
Expand Up @@ -24,7 +24,9 @@

#include <dispatch/dispatch.h>

#if !defined(_WIN32)
#include <dlfcn.h>
#endif

using namespace swift;
using FutureFragment = AsyncTask::FutureFragment;
Expand Down Expand Up @@ -534,10 +536,17 @@ void swift::swift_continuation_logFailedCheck(const char *message) {
}

void swift::swift_task_asyncMainDrainQueue() {
#if !defined(_WIN32)
auto runLoop =
reinterpret_cast<void (*)(void)>(dlsym(RTLD_DEFAULT, "CFRunLoopRun"));
if (runLoop)
runLoop();
else
dispatch_main();
#else
// TODO: I don't have a windows box to get this working right now.
// We need to either pull in the CFRunLoop if it's available, or do
// something that will drain the main queue. Exploding for now.
abort();
#endif
}
1 change: 1 addition & 0 deletions test/Concurrency/async_main.swift
Expand Up @@ -4,6 +4,7 @@

// REQUIRES: concurrency
// REQUIRES: executable_test
// REQUIRES: OS=macosx || OS=ios

func asyncFunc() async {
print("Hello World!")
Expand Down
1 change: 1 addition & 0 deletions test/Concurrency/async_main_throws_prints_error.swift
Expand Up @@ -6,6 +6,7 @@

// REQUIRES: concurrency
// REQUIRES: executable_test
// REQUIRES: OS=macosx || OS=ios

enum Err : Error { case noGood }

Expand Down

0 comments on commit 13cc56b

Please sign in to comment.