Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[coroutine] Fix error C7651 #12456

Merged
merged 2 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions ports/coroutine/CONTROL

This file was deleted.

68 changes: 68 additions & 0 deletions ports/coroutine/fix-errorC7651.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
diff --git a/modules/portable/frame.cpp b/modules/portable/frame.cpp
index 2cedf81..f413f28 100644
--- a/modules/portable/frame.cpp
+++ b/modules/portable/frame.cpp
@@ -77,13 +77,31 @@ size_t _coro_done(void*);
//
// intrinsic: Clang/GCC
//
-extern "C" {
-bool __builtin_coro_done(void*);
-void __builtin_coro_resume(void*);
-void __builtin_coro_destroy(void*);
-// void* __builtin_coro_promise(void* ptr, int align, bool p);
+//extern "C" {
+template <bool B>
+void resume_wrapper(void *p)
+{
+ if constexpr (B)
+ __builtin_coro_resume(p);
+}
+
+template <bool B>
+void destroy_wrapper(void *p)
+{
+ if constexpr(B)
+ __builtin_coro_destroy(p);
}

+template <bool B>
+bool done_wrapper(void *p)
+{
+ if constexpr(B)
+ return __builtin_coro_done(p);
+ return false;
+}
+// void* __builtin_coro_promise(void* ptr, int align, bool p);
+//}
+
bool _coro_finished(portable_coro_prefix* _Handle);

#if defined(__clang__)
@@ -124,7 +142,7 @@ bool portable_coro_done(portable_coro_prefix* _Handle) {
if constexpr (is_msvc) {
return _coro_finished(_Handle);
} else if constexpr (is_clang) {
- return __builtin_coro_done(_Handle);
+ return done_wrapper<true>(_Handle);
}
return false; // follow `noop_coroutine`
}
@@ -133,7 +151,7 @@ void portable_coro_resume(portable_coro_prefix* _Handle) {
if constexpr (is_msvc) {
_coro_resume(_Handle);
} else if constexpr (is_clang) {
- __builtin_coro_resume(_Handle);
+ resume_wrapper<true>(_Handle);
}
}

@@ -141,7 +159,7 @@ void portable_coro_destroy(portable_coro_prefix* _Handle) {
if constexpr (is_msvc) {
_coro_destroy(_Handle);
} else if constexpr (is_clang) {
- __builtin_coro_destroy(_Handle);
+ destroy_wrapper<true>(_Handle);
}
}

1 change: 1 addition & 0 deletions ports/coroutine/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vcpkg_from_github(
REF 1.5.0
SHA512 61b91fdc641b6905b884e99c5bf193ec2cf6962144ab3baafdb9432115757d96f3797f116b30356f0d21417b23082bc908f75042721caeab3329c4910b654594
HEAD_REF master
PATCHES fix-errorC7651.patch
)

vcpkg_configure_cmake(
Expand Down
11 changes: 11 additions & 0 deletions ports/coroutine/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "coroutine",
"version-string": "1.5.0",
"port-version": "1",
"description": "C++ 20 Coroutines helper/example library",
"homepage": "https://github.com/luncliff/coroutine",
"dependencies": [
"ms-gsl"
],
"supports": "!uwp"
}