Ejemplo n.º 1
0
Archivo: exch_n.c Proyecto: 0day-ci/gcc
UTYPE
SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel)
{
  if (maybe_specialcase_relaxed(smodel))
    return __atomic_exchange_n (mptr, newval, __ATOMIC_RELAXED);
  else if (maybe_specialcase_acqrel(smodel))
    return __atomic_exchange_n (mptr, newval, __ATOMIC_ACQ_REL);
  else
    return __atomic_exchange_n (mptr, newval, __ATOMIC_SEQ_CST);
}
Ejemplo n.º 2
0
bool
SIZE(libat_test_and_set) (UTYPE *mptr, int smodel)
{
  if (maybe_specialcase_relaxed(smodel))
    return __atomic_test_and_set (mptr, __ATOMIC_RELAXED);
  else if (maybe_specialcase_acqrel(smodel))
    return __atomic_test_and_set (mptr, __ATOMIC_ACQ_REL);
  else
    return __atomic_test_and_set (mptr, __ATOMIC_SEQ_CST);
}
Ejemplo n.º 3
0
UTYPE
SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel)
{
    if (maybe_specialcase_relaxed(smodel))
        return C3(__atomic_,NAME,_fetch) (mptr, opval, __ATOMIC_RELAXED);
    else if (maybe_specialcase_acqrel(smodel))
        return C3(__atomic_,NAME,_fetch) (mptr, opval, __ATOMIC_ACQ_REL);
    else
        return C3(__atomic_,NAME,_fetch) (mptr, opval, __ATOMIC_SEQ_CST);
}
Ejemplo n.º 4
0
UTYPE
SIZE(libat_load) (UTYPE *mptr, int smodel)
{
  if (maybe_specialcase_relaxed(smodel))
    return __atomic_load_n (mptr, __ATOMIC_RELAXED);
  else if (maybe_specialcase_acqrel(smodel))
    /* Note that REL and ACQ_REL are not valid for loads.  */
    return __atomic_load_n (mptr, __ATOMIC_ACQUIRE);
  else
    return __atomic_load_n (mptr, __ATOMIC_SEQ_CST);
}
Ejemplo n.º 5
0
void
SIZE(libat_store) (UTYPE *mptr, UTYPE newval, int smodel)
{
    if (maybe_specialcase_relaxed(smodel))
        __atomic_store_n (mptr, newval, __ATOMIC_RELAXED);
    else if (maybe_specialcase_acqrel(smodel))
        /* Note that ACQ and ACQ_REL are not valid for store.  */
        __atomic_store_n (mptr, newval, __ATOMIC_RELEASE);
    else
        __atomic_store_n (mptr, newval, __ATOMIC_SEQ_CST);
}
Ejemplo n.º 6
0
void
SIZE(libat_store) (UTYPE *mptr, UTYPE val, int smodel)
{
  if (maybe_specialcase_relaxed(smodel))
    *mptr = val;
  else
    {
      __kernel_dmb ();
      *mptr = val;
      __kernel_dmb ();
    }
}
Ejemplo n.º 7
0
bool
SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
			      int smodel, int fmodel UNUSED)
{
  if (maybe_specialcase_relaxed(smodel))
    return atomic_compare_exchange_n (mptr, eptr, newval, false,
				      __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  else if (maybe_specialcase_acqrel(smodel))
    return atomic_compare_exchange_n (mptr, eptr, newval, false,
				      __ATOMIC_ACQ_REL, __ATOMIC_RELAXED);
  else
    return atomic_compare_exchange_n (mptr, eptr, newval, false,
				      __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
}
Ejemplo n.º 8
0
UTYPE
SIZE(libat_load) (UTYPE *mptr, int smodel)
{
  UTYPE ret;

  if (maybe_specialcase_relaxed(smodel))
    ret = *mptr;
  else
    {
      __kernel_dmb ();
      ret = *mptr;
      __kernel_dmb ();
    }
  return ret;
}
Ejemplo n.º 9
0
UTYPE
SIZE(libat_load) (UTYPE *mptr, int smodel)
{
  UTYPE t = 0;

  if (maybe_specialcase_relaxed(smodel))
    atomic_compare_exchange_n (mptr, &t, 0, true,
			       __ATOMIC_RELAXED, __ATOMIC_RELAXED);
  else if (maybe_specialcase_acqrel(smodel))
    atomic_compare_exchange_n (mptr, &t, 0, true,
			       __ATOMIC_ACQ_REL, __ATOMIC_ACQ_REL);
  else
    atomic_compare_exchange_n (mptr, &t, 0, true,
                               __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);

  return t;
}