/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Generic C implementation of atomic counter operations. Do not include in * machine independent code. * * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com)
*/ #ifndef __ASM_GENERIC_ATOMIC_H #define __ASM_GENERIC_ATOMIC_H
#include <asm/cmpxchg.h> #include <asm/barrier.h>
#ifdef CONFIG_SMP
/* we can build all atomic primitives from cmpxchg */
#define ATOMIC_OP(op, c_op) \ staticinlinevoid generic_atomic_##op(int i, atomic_t *v) \
{ \ int c, old; \
\
c = v->counter; \ while ((old = arch_cmpxchg(&v->counter, c, c c_op i)) != c) \
c = old; \
}
#define ATOMIC_OP_RETURN(op, c_op) \ staticinlineint generic_atomic_##op##_return(int i, atomic_t *v) \
{ \ int c, old; \
\
c = v->counter; \ while ((old = arch_cmpxchg(&v->counter, c, c c_op i)) != c) \
c = old; \
\ return c c_op i; \
}
#define ATOMIC_FETCH_OP(op, c_op) \ staticinlineint generic_atomic_fetch_##op(int i, atomic_t *v) \
{ \ int c, old; \
\
c = v->counter; \ while ((old = arch_cmpxchg(&v->counter, c, c c_op i)) != c) \
c = old; \
\ return c; \
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.