Update contrib.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32\common\arm\atomic_ops.h
32 #undef __SIGN_EXTEND__
33 #undef __LOG2_DATA_SIZE__
47 #undef ENSURE_8BYTE_ALIGNMENT
49 #else // __OPERATION__
51 #if defined(__OP_LOAD__)
52 #define __OPERATION__ load
53 #elif defined(__OP_STORE__)
54 #define __OPERATION__ store
55 #elif defined(__OP_SWP__)
56 #define __OPERATION__ swp
58 #elif defined(__OP_CAS__)
59 #define __OPERATION__ cas
60 #elif defined(__OP_ADD__)
61 #define __OPERATION__ add
63 #elif defined(__OP_AND__)
64 #define __OPERATION__ and
66 #elif defined(__OP_IOR__)
67 #define __OPERATION__ ior
69 #elif defined(__OP_XOR__)
70 #define __OPERATION__ xor
72 #elif defined(__OP_AXO__)
73 #define __OPERATION__ axo
75 #elif defined(__OP_TAU__)
76 #define __OPERATION__ tau
78 #elif defined(__OP_TAS__)
79 #define __OPERATION__ tas
83 #error Unknown atomic operation
87 #define __LOG2_DATA_SIZE__ 3
88 #define __SIZE_CODE__ "b"
89 #ifdef __CPU_ARM_HAS_LDREX_STREX_V6K
90 #define __LDREX_INST__(Rd,Rn) LDREXB(Rd,Rn)
91 #define __STREX_INST__(Rd,Rm,Rn) STREXB(Rd,Rm,Rn)
93 #define __SIGN_EXTEND__(reg) asm("mov "#reg ", "#reg ", lsl #24 "); asm("mov "#reg ", "#reg ", asr #24 ");
94 #define __LDR_INST__(cc,args) asm("ldr"#cc "b " args)
95 #define __LDRS_INST__(cc,args) asm("ldr"#cc "sb " args)
96 #define __STR_INST__(cc,args) asm("str"#cc "b " args)
98 #define __TYPE__ TInt8
100 #define __TYPE__ TUint8
102 #elif __DATA_SIZE__==16
103 #define __LOG2_DATA_SIZE__ 4
104 #define __SIZE_CODE__ "h"
105 #ifdef __CPU_ARM_HAS_LDREX_STREX_V6K
106 #define __LDREX_INST__(Rd,Rn) LDREXH(Rd,Rn)
107 #define __STREX_INST__(Rd,Rm,Rn) STREXH(Rd,Rm,Rn)
109 #define __SIGN_EXTEND__(reg) asm("mov "#reg ", "#reg ", lsl #16 "); asm("mov "#reg ", "#reg ", asr #16 ");
110 #define __LDR_INST__(cc,args) asm("ldr"#cc "h " args)
111 #define __LDRS_INST__(cc,args) asm("ldr"#cc "sh " args)
112 #define __STR_INST__(cc,args) asm("str"#cc "h " args)
114 #define __TYPE__ TInt16
116 #define __TYPE__ TUint16
118 #elif __DATA_SIZE__==32
119 #define __LOG2_DATA_SIZE__ 5
120 #define __SIZE_CODE__ ""
121 #ifdef __CPU_ARM_HAS_LDREX_STREX
122 #define __LDREX_INST__(Rd,Rn) LDREX(Rd,Rn)
123 #define __STREX_INST__(Rd,Rm,Rn) STREX(Rd,Rm,Rn)
125 #define __SIGN_EXTEND__(reg)
126 #define __LDR_INST__(cc,args) asm("ldr"#cc " " args)
127 #define __LDRS_INST__(cc,args) asm("ldr"#cc " " args)
128 #define __STR_INST__(cc,args) asm("str"#cc " " args)
130 #define __TYPE__ TInt32
132 #define __TYPE__ TUint32
134 #elif __DATA_SIZE__==64
135 #define __LOG2_DATA_SIZE__ 6
136 #define __SIZE_CODE__ "d"
137 #ifdef __CPU_ARM_HAS_LDREX_STREX_V6K
138 #define __LDREX_INST__(Rd,Rn) LDREXD(Rd,Rn)
139 #define __STREX_INST__(Rd,Rm,Rn) STREXD(Rd,Rm,Rn)
142 #define __TYPE__ TInt64
144 #define __TYPE__ TUint64
147 #error Invalid data size
150 #if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__EABI__)
151 // Check 8 byte aligned and cause alignment fault if not.
152 // Doesn't work if alignment checking is disabled but gives consistent behaviour
153 // between processors with ldrexd etc and these hand coded versions.
154 #define ENSURE_8BYTE_ALIGNMENT(rAddr) \
155 asm("tst r"#rAddr", #0x7 "); \
156 asm("orrne r"#rAddr", r"#rAddr", #1 "); \
157 asm("ldmne r"#rAddr", {r"#rAddr"} ")
159 // Don't assert on old gcc (arm4) as it is not eabi compliant and this stops
161 #define ENSURE_8BYTE_ALIGNMENT(rAddr)
163 #endif // __OPERATION__