5dc9afe13f0d0f1c30d0d65bcaa0788fa48a3534
1 /* $Id: interlck.c,v 1.6 1999/12/11 21:14:48 dwelch Exp $
3 * reactos/ntoskrnl/rtl/interlck.c
5 * FIXME: change decorated names when __fastcall will be available
6 * (for both egcs 1.1.2 and gcc 2.95 FASTCALL == STDCALL).
8 #include <reactos/config.h>
10 #include <internal/debug.h>
13 LONG FASTCALL
InterlockedIncrement(PLONG Addend
)
21 LONG FASTCALL
InterlockedDecrement(PLONG Addend
)
30 /**********************************************************************
31 * FASTCALL: @InterlockedIncrement@0
32 * STDCALL : _InterlockedIncrement@4
35 LONG FASTCALL
InterlockedIncrement (PLONG Addend
);
37 * FUNCTION: Increments a caller supplied variable of type LONG as an
40 * Addend = Points to a variable whose value is to be increment
41 * RETURNS: The incremented value
43 __asm__("\n\t.global _InterlockedIncrement@4\n\t"
44 "_InterlockedIncrement@4:\n\t"
49 "movl 8(%ebp),%ebx\n\t"
50 "xaddl %eax,(%ebx)\n\t"
61 #ifndef CONFIG_USE_FASTCALL
62 ".global _InterlockedIncrement@4\n"
63 "\t_InterlockedIncrement@4:\n"
64 "\tmovl 4(%esp), %ecx\n"
66 ".global @InterlockedIncrement@0\n"
67 "\t@InterlockedIncrement@0:\n"
72 #ifndef CONFIG_USE_FASTCALL
79 /**********************************************************************
80 * FASTCALL: @InterlockedDecrement@0
81 * STDCALL : _InterlockedDecrement@4
84 LONG FASTCALL
InterlockedDecrement(PLONG Addend
);
85 __asm__("\n\t.global _InterlockedDecrement@4\n\t"
86 "_InterlockedDecrement@4:\n\t"
91 "movl 8(%ebp),%ebx\n\t"
92 "xaddl %eax,(%ebx)\n\t"
100 /**********************************************************************
101 * FASTCALL: @InterlockedExchange@0
102 * STDCALL : _InterlockedExchange@8
106 InterlockedExchange (
111 "\n\t.global _InterlockedExchange@8\n\t"
112 "_InterlockedExchange@8:\n\t"
116 "movl 12(%ebp),%eax\n\t"
117 "movl 8(%ebp),%ebx\n\t"
118 "xchgl %eax,(%ebx)\n\t"
126 #ifndef CONFIG_USE_FASTCALL
127 ".global _InterlockedExchange@8\n"
128 "_InterlockedExchange@8:\n"
129 "\tmovl 4(%esp), %ecx\n"
130 "\tmovl 8(%esp), %edx\n"
132 ".global @InterlockedExchange@0\n"
133 "@InterlockedExchange@0:\n"
135 "\tmovl %ecx, %eax\n"
136 "__InterlockedExchange_Loop:\n"
138 "\tcmpxchg %ecx, %edx\n"
139 "\tjne __InterlockedExchange_Loop\n"
140 #ifndef CONFIG_USE_FASTCALL
141 "\tmovl %ecx, 4(%esp)\n"
150 /**********************************************************************
151 * FASTCALL: @InterlockedExchangeAdd@0
152 * STDCALL : _InterlockedExchangeAdd@8
156 InterlockedExchangeAdd (
161 "\n\t.global _InterlockedExchangeAdd@8\n\t"
162 "_InterlockedExchangeAdd@8:\n\t"
163 "movl 8(%esp),%eax\n\t"
164 "movl 4(%esp),%ebx\n\t"
165 "xaddl %eax,(%ebx)\n\t"
170 #ifndef CONFIG_USE_FASTCALL
171 ".global _InterlockedExchangeAdd@8\n"
172 "\t_InterlockedExchangeAdd@8:\n"
173 "\tmovl 4(%esp), %ecx\n"
174 "\tmovl 8(%esp), %edx\n"
176 ".global @InterlockedExchangeAdd@0\n"
177 "\t@InterlockedExchangeAdd@0:\n"
179 "\txadd %edx, %ecx\n"
180 "\tmovl %edx, %eax\n"
181 #ifndef CONFIG_USE_FASTCALL
190 /**********************************************************************
191 * FASTCALL: @InterlockedCompareExchange@4
192 * STDCALL : _InterlockedCompareExchange@12
196 InterlockedCompareExchange (
202 "\n\t.global _InterlockedCompareExchange@12\n\t"
203 "_InterlockedCompareExchange@12:\n\t"
204 "movl 12(%esp),%eax\n\t"
205 "movl 8(%esp),%edx\n\t"
206 "movl 4(%esp),%ebx\n\t"
207 "cmpxchg %edx,(%ebx)\n\t"
213 #ifndef CONFIG_USE_FASTCALL
214 ".global _InterlockedCompareExchange@12\n"
215 "\t_InterlockedCompareExchange@12:\n"
216 "\tmovl 4(%esp), %ecx\n"
217 "\tmovl 8(%esp), %edx\n"
218 "\tmovl 12(%esp), %eax\n"
220 ".global @InterlockedCompareExchange@4\n"
221 "\t@InterlockedCompareExchange@4:\n"
222 "\tmovl 4(%esp), %eax\n"
224 "\tcmpxchg %ecx, %edx\n"
225 #ifndef CONFIG_USE_FASTCALL