atomic.h (6e9041c6ddd6cbdc61d87bcaca8ca7bb17c28377) atomic.h (febdbfe8a91ce0d11939d4940b592eb0dba8d663)
1/*
2 * Generic C implementation of atomic counter operations. Usable on
3 * UP systems only. Do not include in machine independent code.
4 *
5 * Originally implemented for MN10300.
6 *
7 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
8 * Written by David Howells (dhowells@redhat.com)
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public Licence
12 * as published by the Free Software Foundation; either version
13 * 2 of the Licence, or (at your option) any later version.
14 */
15#ifndef __ASM_GENERIC_ATOMIC_H
16#define __ASM_GENERIC_ATOMIC_H
17
18#include <asm/cmpxchg.h>
1/*
2 * Generic C implementation of atomic counter operations. Usable on
3 * UP systems only. Do not include in machine independent code.
4 *
5 * Originally implemented for MN10300.
6 *
7 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
8 * Written by David Howells (dhowells@redhat.com)
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public Licence
12 * as published by the Free Software Foundation; either version
13 * 2 of the Licence, or (at your option) any later version.
14 */
15#ifndef __ASM_GENERIC_ATOMIC_H
16#define __ASM_GENERIC_ATOMIC_H
17
18#include <asm/cmpxchg.h>
19#include <asm/barrier.h>
19
20#ifdef CONFIG_SMP
21/* Force people to define core atomics */
22# if !defined(atomic_add_return) || !defined(atomic_sub_return) || \
23 !defined(atomic_clear_mask) || !defined(atomic_set_mask)
24# error "SMP requires a little arch-specific magic"
25# endif
26#endif

--- 150 unchanged lines hidden (view full) ---

177 unsigned long flags;
178
179 raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */
180 v->counter |= mask;
181 raw_local_irq_restore(flags);
182}
183#endif
184
20
21#ifdef CONFIG_SMP
22/* Force people to define core atomics */
23# if !defined(atomic_add_return) || !defined(atomic_sub_return) || \
24 !defined(atomic_clear_mask) || !defined(atomic_set_mask)
25# error "SMP requires a little arch-specific magic"
26# endif
27#endif

--- 150 unchanged lines hidden (view full) ---

178 unsigned long flags;
179
180 raw_local_irq_save(flags); /* Don't trace it in a irqsoff handler */
181 v->counter |= mask;
182 raw_local_irq_restore(flags);
183}
184#endif
185
185/* Assume that atomic operations are already serializing */
186#define smp_mb__before_atomic_dec() barrier()
187#define smp_mb__after_atomic_dec() barrier()
188#define smp_mb__before_atomic_inc() barrier()
189#define smp_mb__after_atomic_inc() barrier()
190
191#endif /* __KERNEL__ */
192#endif /* __ASM_GENERIC_ATOMIC_H */
186#endif /* __KERNEL__ */
187#endif /* __ASM_GENERIC_ATOMIC_H */