<atomic.h> and single-byte CAS

Florian Weimer fweimer@redhat.com
Mon Jul 8 14:35:00 GMT 2019


* Andreas Schwab:

> On Jul 08 2019, Florian Weimer <fweimer@redhat.com> wrote:
>
>> atomic_compare_exchange_weak_relaxed with char * arguments, swapping
>> individual bytes.
>
> In which way is it not supported?

_Bool
test_atomic (char *p, char *q)
{
  return atomic_compare_exchange_weak_relaxed (p, q, 1);
}

results in this link-time error on x86-64:

  undefined reference to `__atomic_link_error'

This probably comes from this code:

/* We require 32b atomic operations; some archs also support 64b atomic
   operations.  */
void __atomic_link_error (void);
# if __HAVE_64B_ATOMICS == 1
#  define __atomic_check_size(mem) \
   if ((sizeof (*mem) != 4) && (sizeof (*mem) != 8))			      \
     __atomic_link_error ();
# else
#  define __atomic_check_size(mem) \
   if (sizeof (*mem) != 4)						      \
     __atomic_link_error ();
# endif

Thanks,
Florian



More information about the Libc-alpha mailing list