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

Deprecate Volatile #634

Merged
merged 8 commits into from
Apr 22, 2020
Merged

Deprecate Volatile #634

merged 8 commits into from
Apr 22, 2020

Conversation

miscco
Copy link
Contributor

@miscco miscco commented Mar 24, 2020

Description

grafik

This fixes #558 by removing the appropriate parts from the STL.

I verified those tests that do not require libc++ machinery. For the sake of my sanity someone with acces to a test runner could tell me what I have to change for the tests, as I am not sure whether deprecation is an actual problem and / or whether we would actually want to suppress the warning for the tests.

Checklist

Be sure you've read README.md and understand the scope of this repo.

If you're unsure about a box, leave it unchecked. A maintainer will help you.

  • Identifiers in product code changes are properly _Ugly as per
    https://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
  • The STL builds successfully and all tests have passed (must be manually
    verified by an STL maintainer before automated testing is enabled on GitHub,
    leave this unchecked for initial submission).
  • These changes introduce no known ABI breaks (adding members, renaming
    members, adding virtual functions, changing whether a type is an aggregate
    or trivially copyable, etc.).
  • These changes were written from scratch using only this repository,
    the C++ Working Draft (including any cited standards), other WG21 papers
    (excluding reference implementations outside of proposed standard wording),
    and LWG issues as reference material. If they were derived from a project
    that's already listed in NOTICE.txt, that's fine, but please mention it.
    If they were derived from any other project (including Boost and libc++,
    which are not yet listed in NOTICE.txt), you must mention it here,
    so we can determine whether the license is compatible and what else needs
    to be done.

@miscco miscco requested a review from a team as a code owner March 24, 2020 20:11
@miscco
Copy link
Contributor Author

miscco commented Mar 24, 2020

Me: Lets delete some code 👍

Also me: Adds 274 lines of #ifdef magic

@StephanTLavavej StephanTLavavej added the cxx20 C++20 feature label Mar 24, 2020
@BillyONeal
Copy link
Member

For the sake of my sanity someone with acces to a test runner

Curtis is very very close to landing #520 so that will soon be you :)

@BillyONeal
Copy link
Member

@CaseyCarter Since this is a C++20 only feature can we use a requires clause to turn these off or are there IFNDR concerns since in 20 mode it will always be disabled?

stl/inc/yvals_core.h Outdated Show resolved Hide resolved
stl/inc/yvals_core.h Outdated Show resolved Hide resolved
stl/inc/yvals_core.h Outdated Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
@StephanTLavavej
Copy link
Member

Regarding concepts usage, please see #602.

@miscco
Copy link
Contributor Author

miscco commented Mar 24, 2020

@BillyONeal I actually only went for enable_if_t because the requires clause seemed to have required more line changes and was IMHO less readable, e.g.

#if _HAS_CXX20
    template <class _Type = _Ty, enable_if_t<_Is_always_lock_free<_Type>, int> = 0>
#endif // _HAS_CXX20
    _Ty fetch_sub(const _Ty _Operand) volatile noexcept {
        return fetch_add(_Negate(_Operand));
    }

vs

    _Ty fetch_sub(const _Ty _Operand) volatile noexcept
#if _HAS_CXX20
    requires _Is_always_lock_free<_Type>
#endif // _HAS_CXX20
    {
        return fetch_add(_Negate(_Operand));
    }    

That said, I do not believe it is that bad after all

@BillyONeal
Copy link
Member

@BillyONeal I actually only went for enable_if_t because the requires clause seemed to have required more line changes and was IMHO less readable

That's fair. I'm not arguing for doing that explicitly, only making sure that we aren't avoiding the feature just because we think it is unavailable.

@miscco
Copy link
Contributor Author

miscco commented Mar 27, 2020

Could somebody start a run of the test suite?

@StephanTLavavej
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephanTLavavej
Copy link
Member

We'll probably need to add deprecation suppressions to tr1 too (that's not harnessed in GitHub yet so we'll need to run the Microsoft-internal test harness and push changes to your branch).

@cbezault
Copy link
Contributor

cbezault commented Apr 1, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@miscco
Copy link
Contributor Author

miscco commented Apr 4, 2020

@CaseyCarter I would put those two failing tests in the skip list or are there some other things you would want to try here?

@miscco
Copy link
Contributor Author

miscco commented Apr 10, 2020

Rebased on master and deactivated the two failing libcxx tests.

That said, I am unsure why test for volatile atomic<bool> and volatile atomic<int> fail. They should be always lock free

stl/inc/yvals_core.h Outdated Show resolved Hide resolved
tests/libcxx/expected_results.txt Outdated Show resolved Hide resolved
stl/inc/yvals_core.h Outdated Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
Fixes microsoft#558

Co-Authored-By: Casey Carter <cartec69@gmail.com>
stl/inc/utility Outdated Show resolved Hide resolved
stl/inc/atomic Outdated Show resolved Hide resolved
stl/inc/atomic Outdated
_STD atomic_init(const_cast<atomic<_Ty>*>(_Mem), _Value);
}

template <class _Ty>
void atomic_store(volatile atomic<_Ty>* const _Mem, const _Identity_t<_Ty> _Value) noexcept {
static_assert(_Deprecate_non_lock_free_volatile<_Is_always_lock_free<sizeof(_Ty)>>, "Never fails");
Copy link
Member

Choose a reason for hiding this comment

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

Note to other reviewers: Despite that WG21-P1831 doesn't mention these other non-member functions explicitly, they are specified as equivalent to calling the (now conditionally deprecated) member functions in [atomics.nonmembers]/1, so they should be deprecated.

miscco and others added 2 commits April 13, 2020 08:10
Co-Authored-By: Casey Carter <cartec69@gmail.com>
stl/inc/atomic Outdated Show resolved Hide resolved
Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

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

After pushing the partial specialization change, I noticed that the deprecation machinery in integral/floating/pointer is unnecessary - they are always lock-free even in our current ABI (as their size is <= 8 and they're powers of 2). @CaseyCarter agreed, so I removed those occurrences and added comments. However, I left all of the occurrences in the non-member functions like atomic_fetch_add.

@StephanTLavavej StephanTLavavej self-assigned this Apr 22, 2020
@StephanTLavavej StephanTLavavej merged commit 72c7240 into microsoft:master Apr 22, 2020
@StephanTLavavej
Copy link
Member

Thanks for yet another C++20 feature, @miscco! 😺😸

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

Successfully merging this pull request may close these issues.

P1831R1 Deprecating volatile In The Standard Library
5 participants