std::atomic<packed<dwarf_unit_type, 1>> m_unit_type {(dwarf_unit_type)0};
/* The language of this CU. */
- packed<language, LANGUAGE_BYTES> m_lang = language_unknown;
+ std::atomic<packed<language, LANGUAGE_BYTES>> m_lang {language_unknown};
public:
/* True if this CU has been scanned by the indexer; false if
enum language lang (bool strict_p = true) const
{
+ enum language l = m_lang.load ();
if (strict_p)
- gdb_assert (m_lang != language_unknown);
- return m_lang;
+ gdb_assert (l != language_unknown);
+ return l;
}
void set_lang (enum language lang)
{
if (unit_type () == DW_UT_partial)
return;
- if (m_lang == language_unknown)
- /* Set if not set already. */
- m_lang = lang;
- else
- /* If already set, verify that it's the same value. */
- gdb_assert (m_lang == lang);
+ /* Set if not set already. */
+ packed<language, LANGUAGE_BYTES> nope = language_unknown;
+ if (m_lang.compare_exchange_strong (nope, lang))
+ return;
+ /* If already set, verify that it's the same value. */
+ nope = lang;
+ if (m_lang.compare_exchange_strong (nope, lang))
+ return;
+ gdb_assert_not_reached ();
}
/* Free any cached file names. */