cb85e6a0ae80b83698f2a23ba1630ff53ca3425a
1 #ifndef _ARCH_ATOMIC_S390_H
2 #define _ARCH_ATOMIC_S390_H
5 * Atomic exchange operations for the S390 architecture.
7 * Copyright (C) 2009 Novell, Inc.
8 * Author: Jan Blunck <jblunck@suse.de>
10 * This is taken from the Principles of Operation Appendix A "Conditional
11 * Swapping Instructions (CS, CDS)".
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU Lesser General Public License version 2.1 as
15 * published by the Free Software Foundation.
18 #ifndef __SIZEOF_LONG__
20 #define __SIZEOF_LONG__ 8
22 #define __SIZEOF_LONG__ 4
27 #define BITS_PER_LONG (__SIZEOF_LONG__ * 8)
30 #ifndef _INCLUDE_API_H
32 static __attribute__((always_inline
))
33 unsigned int atomic_exchange_32(volatile unsigned int *addr
, unsigned int val
)
40 : "=&r"(result
), "=m" (*addr
)
41 : "r"(val
), "m" (*addr
)
47 #if (BITS_PER_LONG == 64)
49 static __attribute__((always_inline
))
50 unsigned long atomic_exchange_64(volatile unsigned long *addr
,
58 : "=&r"(result
), "=m" (*addr
)
59 : "r"(val
), "m" (*addr
)
67 static __attribute__((always_inline
))
68 unsigned long _atomic_exchange(volatile void *addr
, unsigned long val
, int len
)
72 return atomic_exchange_32(addr
, val
);
73 #if (BITS_PER_LONG == 64)
75 return atomic_exchange_64(addr
, val
);
78 __asm__
__volatile__(".long 0xd00d00");
84 #define xchg(addr, v) (__typeof__(*(addr))) _atomic_exchange((addr), (v), \
87 #endif /* #ifndef _INCLUDE_API_H */
89 #endif /* ARCH_ATOMIC_S390_H */
This page took 0.031797 seconds and 4 git commands to generate.