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

Replace atomic_ops with std::atomic #3082

Merged
merged 18 commits into from
Jan 24, 2024
Merged

Conversation

d-torrance
Copy link
Member

atomic_ops has been deprecated since C11/C++14. See the message at the top of https://github.com/ivmai/libatomic_ops/blob/master/README.md:

IN NEW CODE, PLEASE USE C11 OR C++14 STANDARD ATOMICS INSTEAD OF THE CORE LIBRARY IN THIS PACKAGE.

Closes: #1113

@d-torrance
Copy link
Member Author

Clang is much pickier about casting atomic_int's to int's than GCC is, but we have finally have all the builds working! I'm not sure how well things that use atomics are covered in the tests, so hopefully nothing is broken...

No longer need to include atomic_ops.h
Previously, it was included via atomic_ops.h.
Used in both d and system directories
We also include atomic-exports.h instead of copy/pasting its
contents.
"load" returns an int anyway, and this was causing a fatal error on
macOS:

CC interrupts-tmp.c
../../../../Macaulay2/d/interrupts.d:25:100: fatal error: used type 'atomic_int' (aka '_Atomic(int)') where arithmetic or pointer type is required
  tmp__5 = (load_Field((*((struct atomic_field*)TS_Get_Local(interrupts_interruptedFlag_id)))) != ((atomic_int)0));
                                                                                                   ^           ~
Otherwise, we get compile errors using clang, e.g.:

CC interrupts-tmp.c
../../../../Macaulay2/d/interrupts.d:25:85: fatal error: used type 'atomic_int' (aka '_Atomic(int)') where arithmetic or pointer type is required
  store_Field((*((struct atomic_field*)TS_Get_Local(interrupts_exceptionFlag_id))),((atomic_int)tmp__4));
                                                                                    ^           ~~~~~~
../../../../Macaulay2/d/../../include/M2/atomic-field.h:20:52: note: expanded from macro 'store_Field'
 #define store_Field(x,val) atomic_store(&(x).field,val)
                                                    ^~~
/Applications/Xcode_14.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include/stdatomic.h:121:66: note: expanded from macro 'atomic_store'
 #define atomic_store(object, desired) __c11_atomic_store(object, desired, __ATOMIC_SEQ_CST)
                                                                  ^~~~~~~
There were lots of things we were never actually using
@mahrud
Copy link
Member

mahrud commented Jan 24, 2024

Are atomic ints in top-level next?

@d-torrance
Copy link
Member Author

Are atomic ints in top-level next?

Yup!

@DanGrayson DanGrayson merged commit d8c6b3a into Macaulay2:development Jan 24, 2024
6 checks 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.

3 participants