Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
switch_x32_unix.h
1/*
2 * this is the internal transfer function.
3 *
4 * HISTORY
5 * 17-Aug-12 Fantix King <fantix.king@gmail.com>
6 * Ported from amd64.
7 */
8
9#define STACK_REFPLUS 1
10
11#ifdef SLP_EVAL
12
13#define STACK_MAGIC 0
14
15#define REGS_TO_SAVE "r12", "r13", "r14", "r15"
16
17
18static int
19slp_switch(void)
20{
21 void* ebp;
22 void* ebx;
23 unsigned int csr;
24 unsigned short cw;
25 int err;
26 int *stackref, stsizediff;
27 __asm__ volatile ("" : : : REGS_TO_SAVE);
28 __asm__ volatile ("fstcw %0" : "=m" (cw));
29 __asm__ volatile ("stmxcsr %0" : "=m" (csr));
30 __asm__ volatile ("movl %%ebp, %0" : "=m" (ebp));
31 __asm__ volatile ("movl %%ebx, %0" : "=m" (ebx));
32 __asm__ ("movl %%esp, %0" : "=g" (stackref));
33 {
34 SLP_SAVE_STATE(stackref, stsizediff);
35 __asm__ volatile (
36 "addl %0, %%esp\n"
37 "addl %0, %%ebp\n"
38 :
39 : "r" (stsizediff)
40 );
41 SLP_RESTORE_STATE();
42 }
43 __asm__ volatile ("movl %0, %%ebx" : : "m" (ebx));
44 __asm__ volatile ("movl %0, %%ebp" : : "m" (ebp));
45 __asm__ volatile ("ldmxcsr %0" : : "m" (csr));
46 __asm__ volatile ("fldcw %0" : : "m" (cw));
47 __asm__ volatile ("" : : : REGS_TO_SAVE);
48 __asm__ volatile ("xorl %%eax, %%eax" : "=a" (err));
49 return err;
50}
51
52#endif
53
54/*
55 * further self-processing support
56 */
57
58/*
59 * if you want to add self-inspection tools, place them
60 * here. See the x86_msvc for the necessary defines.
61 * These features are highly experimental und not
62 * essential yet.
63 */