154
154
&function_end_B("OPENSSL_atomic_add");
156
# This function can become handy under Win32 in situations when
157
# we don't know which calling convention, __stdcall or __cdecl(*),
158
# indirect callee is using. In C it can be deployed as
160
#ifdef OPENSSL_CPUID_OBJ
161
# type OPENSSL_indirect_call(void *f,...);
163
# OPENSSL_indirect_call(func,[up to $max arguments]);
166
# (*) it's designed to work even for __fastcall if number of
167
# arguments is 1 or 2!
168
&function_begin_B("OPENSSL_indirect_call");
170
my $i,$max=7; # $max has to be chosen as 4*n-1
171
# in order to preserve eventual
176
&mov ("ecx",&DWP(12,"ebp"));
177
&mov (&DWP(0,"esp"),"ecx");
178
&mov ("edx",&DWP(16,"ebp"));
179
&mov (&DWP(4,"esp"),"edx");
180
for($i=2;$i<$max;$i++)
182
# Some copies will be redundant/bogus...
183
&mov ("eax",&DWP(12+$i*4,"ebp"));
184
&mov (&DWP(0+$i*4,"esp"),"eax");
186
&call_ptr (&DWP(8,"ebp"));# make the call...
187
&mov ("esp","ebp"); # ... and just restore the stack pointer
188
# without paying attention to what we called,
189
# (__cdecl *func) or (__stdcall *one).
193
&function_end_B("OPENSSL_indirect_call");
156
195
&initseg("OPENSSL_cpuid_setup");