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

osdep: drop atomic fallback #12667

Merged
merged 4 commits into from
Oct 20, 2023

Conversation

N-R-K
Copy link
Contributor

@N-R-K N-R-K commented Oct 18, 2023

even msvc (which mpv apparently doesn't support) supports C11 atomics now. no need to carry around fallback with subtle semantic differences.

@N-R-K
Copy link
Contributor Author

N-R-K commented Oct 18, 2023

Mainly opening this for a discussion, so marked as draft for now.

@N-R-K N-R-K marked this pull request as draft October 18, 2023 14:40
meson.build Outdated Show resolved Hide resolved
meson.build Outdated Show resolved Hide resolved
@N-R-K N-R-K force-pushed the drop-atomic-fallback-question-mark branch from 3d44043 to 84dc46a Compare October 18, 2023 15:06
meson.build Outdated Show resolved Hide resolved
meson.build Outdated Show resolved Hide resolved
osdep/atomic.h Outdated Show resolved Hide resolved
@N-R-K N-R-K force-pushed the drop-atomic-fallback-question-mark branch 2 times, most recently from 8bab3bd to ee08567 Compare October 19, 2023 12:55
options/m_config_core.c Outdated Show resolved Hide resolved
meson.build Show resolved Hide resolved
@N-R-K N-R-K force-pushed the drop-atomic-fallback-question-mark branch from ee08567 to 8fef977 Compare October 19, 2023 14:35
@N-R-K N-R-K marked this pull request as ready for review October 19, 2023 14:45
@N-R-K N-R-K changed the title [RFC] osdep: drop atomic fallback osdep: drop atomic fallback Oct 19, 2023
@N-R-K N-R-K force-pushed the drop-atomic-fallback-question-mark branch from 8fef977 to c4a5c17 Compare October 19, 2023 15:12
@N-R-K N-R-K marked this pull request as draft October 19, 2023 15:42
@N-R-K N-R-K marked this pull request as draft October 19, 2023 15:42
@N-R-K N-R-K force-pushed the drop-atomic-fallback-question-mark branch from 0a12243 to 37adfa1 Compare October 20, 2023 07:03
N-R-K added 3 commits October 20, 2023 13:10
even msvc (which mpv apparently doesn't support) supports C11 atomics
now. no need to carry around fallback with subtle semantic differences.
replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with
explicit _Atomic qualified types.

also add missing config.h includes on some files.
the fallback needed it due to the struct wrapper. but the fallback is
now removed so it's no longer needed.

as for standard atomics, it was never really needed either, was useless
and then made obsolete in C17 and removed in C23.

ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/
ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
@N-R-K N-R-K force-pushed the drop-atomic-fallback-question-mark branch from 37adfa1 to 045cfa9 Compare October 20, 2023 07:11
@N-R-K N-R-K marked this pull request as ready for review October 20, 2023 08:02
@Dudemanguy
Copy link
Member

Worth removing all mention of C99 in the docs too.

@N-R-K
Copy link
Contributor Author

N-R-K commented Oct 20, 2023

Worth removing all mention of C99 in the docs too.

Which ones? All the atomic related ones are removed as far as I see.

If you meant in general, then yeah the docs are a bit outdated on certain places and could use an update to make it reflect the reality of the codebase more accurately. But I don't think this PR is the proper place to do it.

osdep/windows_utils.c Outdated Show resolved Hide resolved
@Dudemanguy
Copy link
Member

If you meant in general, then yeah the docs are a bit outdated on certain places and could use an update to make it reflect the reality of the codebase more accurately.

Well I dunno, I viewed this PR as a more general "stop pretending mpv isn't C11" kind of thing, but I guess if you want to keep it to strictly the atomic thing I guess that's fine.

since i was going to fix the include order of stdatomic, might as well
sort the surrouding includes in accordance with the project's coding
style.

some headers can sometime require specific include order. standard
library headers usually don't. but mpv might "hack into" the standard
headers (e.g pthreads) so that complicates things a bit more.

hopefully nothing breaks. if it does, the style guide is to blame.
@N-R-K N-R-K force-pushed the drop-atomic-fallback-question-mark branch from 045cfa9 to 61b3e0f Compare October 20, 2023 14:30
@github-actions
Copy link

Download the artifacts for this pull request:

Windows

@N-R-K
Copy link
Contributor Author

N-R-K commented Oct 20, 2023

I viewed this PR as a more general "stop pretending mpv isn't C11" kind of thing

For me it was about removing dead code. Most compilers already supports C11 atomics and if they don't, I doubt the fallback would work since it depends on gnu statement expression.

If someone knows of some (not horribly outdated) compiler where it used to build mpv fine on the fallback before but would be broken after this PR, then I'd drop the PR. For some context, even TCC (mob branch) supports C11 atomics.

As for the C99/C11 stuff, the docs say mpv uses a "restricted C11". Me and @kasper93 asked about it on IRC, but no one knew what it meant. So I don't really want to go change stuff that I don't really know about 🤷.

@Dudemanguy
Copy link
Member

As for the C99/C11 stuff, the docs say mpv uses a "restricted C11". Me and @kasper93 asked about it on IRC, but no one knew what it meant.

The person that wrote that and knew what it meant isn't around anymore. ;) My guess is simply because that was written roughly 10 years ago when C11 was actually relatively new.

@kasper93
Copy link
Contributor

kasper93 commented Oct 20, 2023

I don't see any issues with using C11 fully today. We set it in compiler flags anyway, it is like only docs need to be changed. And removing dead code can follow.

Copy link
Member

@Dudemanguy Dudemanguy left a comment

Choose a reason for hiding this comment

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

Looks OK. We can follow up with doc stuff afterwards.

@sfan5 sfan5 merged commit d05ef7f into mpv-player:master Oct 20, 2023
14 checks passed
@N-R-K N-R-K deleted the drop-atomic-fallback-question-mark branch October 20, 2023 19:35
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.

4 participants