This is an archive of the discontinued LLVM Phabricator instance.

[AIX][RFC] Undefine __STDC_NO_ATOMICS__ to enable c11 atomics functionality
Needs ReviewPublic

Authored by lkail on Sep 2 2021, 1:44 AM.

Details

Reviewers
hubert.reinterpretcast
cebowleratibm
Jake-Egan
daltenty
jsji
Group Reviewers
Restricted Project
Summary

In https://reviews.llvm.org/D103707, __STDC_NO_ATOMICS__ is predefined to indicate clang on AIX doesn't support _Atomic and not shipped with stdatomic.h yet. Actually _Atomic is already supported. For stdatomic.h, clang has implemented one in clang/lib/Headers/stdatomic.h. The remaining problem is

void atomic_thread_fence(memory_order);
void atomic_signal_fence(memory_order);
_Bool atomic_flag_test_and_set(volatile atomic_flag *);
_Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *, memory_order);

are defined as macros and don't have external linkage required by C11 standard, since current libc of AIX doesn't have them now. So is it worthwhile to violate the standard a bit, but make c11's atomics functionality available to users? If not, we may have to wait for upgrading of AIX's libc to define above routines.

Diff Detail

Event Timeline

lkail created this revision.Sep 2 2021, 1:44 AM
lkail requested review of this revision.Sep 2 2021, 1:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2021, 1:44 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Hmm, I'm not sure that the limitations you outline in the description are the only problems that cause us to define the macro in the first place (though the lack of libc implementation was part of it). I'll try to dig up the original issues.

For the missing library implementation, we may be able to use the implementation in compiler-rt. Seems like some other platforms do so.

jsji resigned from this revision.Jun 2 2022, 7:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2022, 7:56 AM