2 * Port on Texas Instruments TMS320C6x architecture
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #ifndef _ASM_C6X_CMPXCHG_H
12 #define _ASM_C6X_CMPXCHG_H
14 #include <linux/irqflags.h>
19 static inline unsigned int __xchg(unsigned int x
, volatile void *ptr
, int size
)
24 local_irq_save(flags
);
29 tmp
= *((unsigned char *) ptr
);
30 *((unsigned char *) ptr
) = (unsigned char) x
;
34 tmp
= *((unsigned short *) ptr
);
35 *((unsigned short *) ptr
) = x
;
39 tmp
= *((unsigned int *) ptr
);
40 *((unsigned int *) ptr
) = x
;
43 local_irq_restore(flags
);
47 #define xchg(ptr, x) \
48 ((__typeof__(*(ptr)))__xchg((unsigned int)(x), (void *) (ptr), \
50 #define tas(ptr) xchg((ptr), 1)
53 #include <asm-generic/cmpxchg-local.h>
56 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
59 #define cmpxchg_local(ptr, o, n) \
60 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
64 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
66 #include <asm-generic/cmpxchg.h>
68 #endif /* _ASM_C6X_CMPXCHG_H */