1 /* $Id: interlck.c,v 1.6 2003/12/30 18:52:03 fireball Exp $
3 * reactos/ntoskrnl/ex/i386/interlck.c
11 INTERLOCKED_RESULT FASTCALL
12 Exfi386InterlockedIncrementLong(IN PLONG Addend
);
14 __asm__("\n\t.global @Exfi386InterlockedIncrementLong@4\n\t"
15 "@Exfi386InterlockedIncrementLong@4:\n\t"
18 "andl $0xC000, %eax\n\t"
21 #elif defined(_MSC_VER)
24 INTERLOCKED_RESULT FASTCALL
25 Exfi386InterlockedIncrementLong(IN PLONG Addend
)
34 #error Unknown compiler for inline assembler
40 INTERLOCKED_RESULT FASTCALL
41 Exfi386InterlockedDecrementLong(IN PLONG Addend
);
43 __asm__("\n\t.global @Exfi386InterlockedDecrementLong@4\n\t"
44 "@Exfi386InterlockedDecrementLong@4:\n\t"
47 "andl $0xC000, %eax\n\t"
50 #elif defined(_MSC_VER)
53 INTERLOCKED_RESULT FASTCALL
54 Exfi386InterlockedDecrementLong(IN PLONG Addend
)
63 #error Unknown compiler for inline assembler
70 Exfi386InterlockedExchangeUlong(IN PULONG Target
,
73 __asm__("\n\t.global @Exfi386InterlockedExchangeUlong@8\n\t"
74 "@Exfi386InterlockedExchangeUlong@8:\n\t"
75 "xchgl %edx,(%ecx)\n\t"
79 #elif defined(_MSC_VER)
83 Exfi386InterlockedExchangeUlong(IN PULONG Target
,
92 #error Unknown compiler for inline assembler
98 INTERLOCKED_RESULT STDCALL
99 Exi386InterlockedIncrementLong(IN PLONG Addend
);
101 __asm__("\n\t.global _Exi386InterlockedIncrementLong@4\n\t"
102 "_Exi386InterlockedIncrementLong@4:\n\t"
103 "movl 4(%esp),%eax\n\t"
106 "andl $0xC000, %eax\n\t"
109 #elif defined(_MSC_VER)
112 INTERLOCKED_RESULT STDCALL
113 Exi386InterlockedIncrementLong(IN PLONG Addend
)
115 __asm mov eax
, Addend
118 __asm
and eax
, 0xC000
123 #error Unknown compiler for inline assembler
127 #if defined(__GNUC__)
129 INTERLOCKED_RESULT STDCALL
130 Exi386InterlockedDecrementLong(IN PLONG Addend
);
132 __asm__("\n\t.global _Exi386InterlockedDecrementLong@4\n\t"
133 "_Exi386InterlockedDecrementLong@4:\n\t"
134 "movl 4(%esp),%eax\n\t"
137 "andl $0xC000, %eax\n\t"
140 #elif defined(_MSC_VER)
143 INTERLOCKED_RESULT STDCALL
144 Exi386InterlockedDecrementLong(IN PLONG Addend
)
146 __asm mov eax
, Addend
149 __asm
and eax
, 0xC000
154 #error Unknown compiler for inline assembler
158 #if defined(__GNUC__)
161 Exi386InterlockedExchangeUlong(IN PULONG Target
,
164 __asm__("\n\t.global _Exi386InterlockedExchangeUlong@8\n\t"
165 "_Exi386InterlockedExchangeUlong@8:\n\t"
166 "movl 4(%esp),%edx\n\t"
167 "movl 8(%esp),%eax\n\t"
168 "xchgl %eax,(%edx)\n\t"
171 #elif defined(_MSC_VER)
175 Exi386InterlockedExchangeUlong(IN PULONG Target
,
179 __asm mov eax
, Target
180 __asm xchg
[edx
], eax
185 #error Unknown compiler for inline assembler
190 /**********************************************************************
191 * FASTCALL: @InterlockedIncrement@4
192 * STDCALL : _InterlockedIncrement@4
194 #if defined(__GNUC__)
196 InterlockedIncrement(PLONG Addend
);
198 * FUNCTION: Increments a caller supplied variable of type LONG as an
201 * Addend = Points to a variable whose value is to be increment
202 * RETURNS: The incremented value
205 __asm__("\n\t.global @InterlockedIncrement@4\n\t"
206 "@InterlockedIncrement@4:\n\t"
208 "xaddl %eax,(%ecx)\n\t"
212 #elif defined(_MSC_VER)
216 InterlockedIncrement(PLONG Addend
)
219 __asm xadd
[ecx
], eax
225 #error Unknown compiler for inline assembler
229 /**********************************************************************
230 * FASTCALL: @InterlockedDecrement@4
231 * STDCALL : _InterlockedDecrement@4
233 #if defined(__GNUC__)
235 InterlockedDecrement(PLONG Addend
);
237 __asm__("\n\t.global @InterlockedDecrement@4\n\t"
238 "@InterlockedDecrement@4:\n\t"
240 "xaddl %eax,(%ecx)\n\t"
244 #elif defined(_MSC_VER)
248 InterlockedDecrement(PLONG Addend
)
251 __asm xadd
[ecx
], eax
257 #error Unknown compiler for inline assembler
261 /**********************************************************************
262 * FASTCALL: @InterlockedExchange@8
263 * STDCALL : _InterlockedExchange@8
266 #if defined(__GNUC__)
268 InterlockedExchange(PLONG Target
,
271 __asm__("\n\t.global @InterlockedExchange@8\n\t"
272 "@InterlockedExchange@8:\n\t"
273 "xchgl %edx,(%ecx)\n\t"
277 #elif defined(_MSC_VER)
281 InterlockedExchange(PLONG Target
,
284 __asm xchg
[ecx
], edx
290 #error Unknown compiler for inline assembler
293 /**********************************************************************
294 * FASTCALL: @InterlockedExchangeAdd@8
295 * STDCALL: _InterlockedExchangeAdd@8
297 #if defined(__GNUC__)
300 InterlockedExchangeAdd(PLONG Addend
,
303 __asm__("\n\t.global @InterlockedExchangeAdd@8\n\t"
304 "@InterlockedExchangeAdd@8:\n\t"
305 "xaddl %edx,(%ecx)\n\t"
309 #elif defined(_MSC_VER)
313 InterlockedExchangeAdd(PLONG Addend
,
316 __asm xadd
[ecx
], edx
322 #error Unknown compiler for inline assembler
326 /**********************************************************************
327 * FASTCALL: @InterlockedCompareExchange@12
328 * STDCALL: _InterlockedCompareExchange@12
330 #if defined(__GNUC__)
333 InterlockedCompareExchange(PLONG Destination
,
337 __asm__("\n\t.global @InterlockedCompareExchange@12\n\t"
338 "@InterlockedCompareExchange@12:\n\t"
339 "movl 4(%esp),%eax\n\t"
340 "cmpxchg %edx,(%ecx)\n\t"
343 #elif defined(_MSC_VER)
347 InterlockedCompareExchange(PLONG Destination
,
351 __asm mov eax
, Comperand
352 __asm cmpxchg
[ecx
], edx
357 #error Unknown compiler for inline assembler