More Escapes for the PostScript driver.
[wine.git] / include / stackframe.h
blob0326abd97f2a737eed6c514d5b6e88e403aa0159
1 /*
2 * 16-bit and 32-bit mode stack frame layout
4 * Copyright 1995, 1998 Alexandre Julliard
5 */
7 #ifndef __WINE_STACKFRAME_H
8 #define __WINE_STACKFRAME_H
10 #include "ldt.h"
11 #include "thread.h"
13 #pragma pack(1)
15 /* 32-bit stack layout after CallTo16() */
16 typedef struct _STACK32FRAME
18 SEGPTR frame16; /* 00 16-bit frame from last CallFrom16() */
19 DWORD restore_addr; /* 04 return address for restoring code selector */
20 DWORD codeselector; /* 08 code selector to restore */
21 DWORD edi; /* 0c saved registers */
22 DWORD esi; /* 10 */
23 DWORD edx; /* 14 */
24 DWORD ecx; /* 18 */
25 DWORD ebx; /* 1c */
26 DWORD ebp; /* 20 saved 32-bit frame pointer */
27 DWORD retaddr; /* 24 actual return address */
28 DWORD args[1]; /* 28 arguments to 16-bit function */
29 } STACK32FRAME;
31 /* 16-bit stack layout after CallFrom16() */
32 typedef struct
34 STACK32FRAME *frame32; /* 00 32-bit frame from last CallTo16() */
35 DWORD ebp; /* 04 full 32-bit content of ebp */
36 WORD mutex_count; /* 08 Win16Mutex recursion count */
37 WORD fs; /* 0a fs */
38 WORD entry_ip; /* 0c ip of entry point */
39 WORD ds; /* 0e ds */
40 WORD entry_cs; /* 10 cs of entry point */
41 WORD es; /* 12 es */
42 DWORD entry_point; /* 14 32-bit entry point to call */
43 WORD bp; /* 18 16-bit bp */
44 WORD ip; /* 1a return address */
45 WORD cs; /* 1c */
46 } STACK16FRAME;
48 #pragma pack(4)
50 #define THREAD_STACK16(thdb) ((STACK16FRAME*)PTR_SEG_TO_LIN((thdb)->cur_stack))
51 #define CURRENT_STACK16 (THREAD_STACK16(THREAD_Current()))
52 #define CURRENT_DS (CURRENT_STACK16->ds)
54 /* varargs lists on the 16-bit stack */
56 typedef void *VA_LIST16;
58 #define __VA_ROUNDED16(type) \
59 ((sizeof(type) + sizeof(WORD) - 1) / sizeof(WORD) * sizeof(WORD))
60 #define VA_START16(list) ((list) = (VA_LIST16)(CURRENT_STACK16 + 1))
61 #define VA_ARG16(list,type) \
62 (((list) = (VA_LIST16)((char *)(list) + __VA_ROUNDED16(type))), \
63 *((type *)(void *)((char *)(list) - __VA_ROUNDED16(type))))
64 #define VA_END16(list) ((void)0)
66 /* Push bytes on the 16-bit stack of a thread;
67 * return a segptr to the first pushed byte
69 #define STACK16_PUSH(thdb,size) \
70 (memmove((char*)THREAD_STACK16(thdb)-(size),THREAD_STACK16(thdb), \
71 sizeof(STACK16FRAME)), \
72 (thdb)->cur_stack -= (size), \
73 (SEGPTR)((thdb)->cur_stack + sizeof(STACK16FRAME)))
75 /* Pop bytes from the 16-bit stack of a thread */
76 #define STACK16_POP(thdb,size) \
77 (memmove((char*)THREAD_STACK16(thdb)+(size),THREAD_STACK16(thdb), \
78 sizeof(STACK16FRAME)), \
79 (thdb)->cur_stack += (size))
81 /* Push a DWORD on the 32-bit stack */
82 #define STACK32_PUSH(context,val) (*--((DWORD *)ESP_reg(context)) = (val))
84 /* Pop a DWORD from the 32-bit stack */
85 #define STACK32_POP(context) (*((DWORD *)ESP_reg(context))++)
87 /* Win32 register functions */
88 #define REGS_ENTRYPOINT(name) void WINAPI __regs_##name( CONTEXT *context )
90 #endif /* __WINE_STACKFRAME_H */