Beispiel #1
0
void
test_and ()
{
  v = init;

  __atomic_and_fetch (&v, 0, __ATOMIC_RELAXED);
  if (v != 0)
    abort ();

  v = init;
  __atomic_fetch_and (&v, init, __ATOMIC_CONSUME);
  if (v != init)
    abort ();

  __atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE);
  if (v != 0)
    abort ();

  v = ~v;
  __atomic_fetch_and (&v, init, __ATOMIC_RELEASE);
  if (v != init)
    abort ();

  __atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL);
  if (v != 0)
    abort ();

  v = ~v;
  __atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST);
  if (v != 0)
    abort ();
}
Beispiel #2
0
void ObjectPool::bitset(uint64_t *ptr, size_t pos, char val)
{
    if (val)
        __atomic_fetch_or(ptr, (uint64_t) 1 << pos, __ATOMIC_SEQ_CST);
    else
        __atomic_fetch_and(ptr, ~((uint64_t)1 << pos), __ATOMIC_SEQ_CST);
}
Beispiel #3
0
void test_atomic_bool (_Atomic _Bool *a)
{
  enum { SEQ_CST = __ATOMIC_SEQ_CST };
  
  __atomic_fetch_add (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_add." } */
  __atomic_fetch_sub (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_sub." } */
  __atomic_fetch_and (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_and." } */
  __atomic_fetch_xor (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_xor." } */
  __atomic_fetch_or (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_or." } */
  __atomic_fetch_nand (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_fetch_nand." } */

  __atomic_add_fetch (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_add_fetch." } */
  __atomic_sub_fetch (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_sub_fetch." } */
  __atomic_and_fetch (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_and_fetch." } */
  __atomic_xor_fetch (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_xor_fetch." } */
  __atomic_or_fetch (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_or_fetch." } */
  __atomic_nand_fetch (a, 1, SEQ_CST);   /* { dg-error "operand type ._Atomic _Bool \\*. is incompatible with argument 1 of .__atomic_nand_fetch." } */

  /* The following are valid and must be accepted.  */
  _Bool val = 0, ret = 0;
  __atomic_exchange (a, &val, &ret, SEQ_CST);
  __atomic_exchange_n (a, val, SEQ_CST);
  __atomic_compare_exchange (a, &val, &ret, !1, SEQ_CST, SEQ_CST);
  __atomic_compare_exchange_n (a, &val, ret, !1, SEQ_CST, SEQ_CST);
  __atomic_test_and_set (a, SEQ_CST);
  __atomic_clear (a, SEQ_CST);
}
Beispiel #4
0
__host__ __device__
typename enable_if<
  sizeof(Integer64) == 8,
  Integer64
>::type
atomic_fetch_and(Integer64 *x, Integer64 y)
{
#if defined(__CUDA_ARCH__)
  return atomicAnd(x, y);
#elif defined(__GNUC__)
  return __atomic_fetch_and(x, y, __ATOMIC_SEQ_CST);
#elif defined(_MSC_VER)
  return InterlockedAnd64(x, y);
#elif defined(__clang__)
  return __c11_atomic_fetch_and(x, y)
#else
#error "No atomic_fetch_and implementation."
#endif
}
Beispiel #5
0
int
atomic_fetch_and_ACQUIRE (int a)
{
  return __atomic_fetch_and (&v, a, __ATOMIC_ACQUIRE);
}
Beispiel #6
0
static __int128_t
quad_fetch_and (__int128_t *ptr, __int128_t value)
{
  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
}
Beispiel #7
0
short
short_fetch_and_acquire (short *ptr, int value)
{
  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
}
Beispiel #8
0
char
char_fetch_and_acquire (char *ptr, int value)
{
  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
}
Beispiel #9
0
long
long_fetch_and_acquire (long *ptr, long value)
{
  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
}
Beispiel #10
0
void
hle_and (int *p, int v)
{
  __atomic_fetch_and (p, v, __ATOMIC_ACQUIRE | __ATOMIC_HLE_ACQUIRE);
}
Beispiel #11
0
long
atomic_fetch_and_RELAXED (long a)
{
  return __atomic_fetch_and (&v, a, __ATOMIC_RELAXED);
}
P_LIB_API puint
p_atomic_int_and (volatile puint	*atomic,
		  puint			val)
{
	return (puint) __atomic_fetch_and (atomic, val, __ATOMIC_SEQ_CST);
}
P_LIB_API psize
p_atomic_pointer_and (volatile void	*atomic,
		      psize		val)
{
	return (psize) __atomic_fetch_and ((volatile psize *) atomic, val, __ATOMIC_SEQ_CST);
}
Beispiel #14
0
void
hle_and (int *p, int v)
{
  __atomic_fetch_and (p, v, __ATOMIC_RELEASE | __ATOMIC_HLE_RELEASE);
}
Beispiel #15
0
int
atomic_fetch_and_SEQ_CST ()
{
  return __atomic_fetch_and (&v, 4096, __ATOMIC_SEQ_CST);
}