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

Avoid std::atomic_init deprecated by P0883. #140

Merged
merged 2 commits into from
Jan 28, 2020
Merged

Avoid std::atomic_init deprecated by P0883. #140

merged 2 commits into from
Jan 28, 2020

Conversation

BillyONeal
Copy link
Contributor

Resolves #139

I don't think I've been successful in actually getting this to build; I apologize if there are typos here:

image

@lewissbaker
Copy link
Owner

I don't think I've been successful in actually getting this to build;

The build system is currently only looking for VS2017 compilers.
You will need to pull in the vs2019 branch to get the build system to find the VS2019 compiler (See PR #125).

Copy link
Owner

@lewissbaker lewissbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

If you can fix up the multi_producer_sequencer constructor it should be good to merge.

@@ -508,11 +508,13 @@ namespace cppcoro
constexpr unsigned_diff_t maxSize = static_cast<unsigned_diff_t>(std::numeric_limits<diff_t>::max());
assert(bufferSize <= maxSize);

#ifndef __cpp_lib_atomic_value_initialization
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop still needs to run to initialise the elements of the array.
Each element is initialised to a different value (notice that seq is incremented inside the while condition).

Maybe something like this:

 SEQUENCE seq = initialSequence - (bufferSize - 1);
 do
 {
+#if __cpp_lib_atomic_value_initialization
+    m_published[seq & m_sequenceMask].store(seq, std::memory_order_relaxed);
+#else
     std::atomic_init(&m_published[seq & m_sequenceMask], seq);
+#endif
 } while (seq++ != initialSequence);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed up, thank you!

@BillyONeal
Copy link
Contributor Author

The build system is currently only looking for VS2017 compilers.

Right, I put the VS2017 compiler on the PATH. (That's the -vcvars_ver=14.16.x in the dev prompt command) But I guess it might be looking in the 2017 installation directory or something like that.

This loop still needs to run to initialise the elements of the array.

Derp, stand by.

Copy link
Owner

@lewissbaker lewissbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I guess it might be looking in the 2017 installation directory or something like that.

It uses vswhere to find the install-location of msvc.
I try to avoid relying on environment variables to help make the build a bit more repeatable.

You can modify the config.cake file to set the vcInstallDir variable explicitly as a last resort (it's just a Python script). I should probably add a command-line flag to allow setting this, as it does for clang.

@lewissbaker lewissbaker merged commit 926b032 into lewissbaker:master Jan 28, 2020
@BillyONeal BillyONeal deleted the remove_atomic_init branch January 28, 2020 23:24
@BillyONeal
Copy link
Contributor Author

FYI, this ran against our compiler nightly builds last night and passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

atomic_init calls throw deprecation warnings after acceptance of C++20 P0883
2 participants