~ubuntu-branches/ubuntu/maverick/openssl/maverick

« back to all changes in this revision

Viewing changes to crypto/x86cpuid.pl

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2006-05-15 16:00:58 UTC
  • mto: (11.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20060515160058-pg6lnbkkpkwpdj2e
Tags: upstream-0.9.8b
ImportĀ upstreamĀ versionĀ 0.9.8b

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
        &ret    ();
154
154
&function_end_B("OPENSSL_atomic_add");
155
155
 
 
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
 
159
#
 
160
#ifdef OPENSSL_CPUID_OBJ
 
161
#       type OPENSSL_indirect_call(void *f,...);
 
162
#       ...
 
163
#       OPENSSL_indirect_call(func,[up to $max arguments]);
 
164
#endif
 
165
#
 
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");
 
169
        {
 
170
        my $i,$max=7;           # $max has to be chosen as 4*n-1
 
171
                                # in order to preserve eventual
 
172
                                # stack alignment
 
173
        &push   ("ebp");
 
174
        &mov    ("ebp","esp");
 
175
        &sub    ("esp",$max*4);
 
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++)
 
181
                {
 
182
                # Some copies will be redundant/bogus...
 
183
                &mov    ("eax",&DWP(12+$i*4,"ebp"));
 
184
                &mov    (&DWP(0+$i*4,"esp"),"eax");
 
185
                }
 
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).
 
190
        &pop    ("ebp");
 
191
        &ret    ();
 
192
        }
 
193
&function_end_B("OPENSSL_indirect_call");
 
194
 
156
195
&initseg("OPENSSL_cpuid_setup");
157
196
 
158
197
&asm_finish();