Use the Pentium's rdtsc instruction (if available) to implement
[wine/multimedia.git] / include / callback.h
blob5be74d00011dc9873b6dbd06fdc4340f5fca8d28
1 /*
2 * Callback functions
4 * Copyright 1995 Alexandre Julliard
5 */
7 #ifndef __WINE_CALLBACK_H
8 #define __WINE_CALLBACK_H
10 #include "windef.h"
11 #include "winnt.h"
12 #include "wingdi.h"
13 #include "wine/winuser16.h"
15 extern void SYSDEPS_SwitchToThreadStack( void (*func)(void) ) WINE_NORETURN;
17 typedef void (*RELAY)();
18 extern FARPROC THUNK_Alloc( FARPROC16 func, RELAY relay );
19 extern void THUNK_Free( FARPROC thunk );
20 extern BOOL THUNK_Init(void);
21 extern void THUNK_InitCallout(void);
24 typedef struct
26 BOOL WINAPI (*PeekMessageA)( LPMSG, HWND, UINT, UINT, UINT );
27 BOOL WINAPI (*GetMessageA)( MSG*, HWND, UINT, UINT );
28 LRESULT WINAPI (*SendMessageA)( HWND, UINT, WPARAM, LPARAM );
29 BOOL WINAPI (*PostMessageA)( HWND, UINT, WPARAM, LPARAM );
30 BOOL WINAPI (*TranslateMessage)( const MSG *msg );
31 LONG WINAPI (*DispatchMessageA)( const MSG* msg );
32 BOOL WINAPI (*RedrawWindow)( HWND, const RECT *, HRGN, UINT );
33 WORD WINAPI (*UserSignalProc)( UINT, DWORD, DWORD, HMODULE16 );
34 void WINAPI (*FinalUserInit16)( void );
35 HQUEUE16 WINAPI (*InitThreadInput16)( WORD, WORD );
36 void WINAPI (*UserYield16)( void );
37 WORD WINAPI (*DestroyIcon32)( HGLOBAL16, UINT16 );
38 DWORD WINAPI (*WaitForInputIdle)( HANDLE, DWORD );
39 DWORD WINAPI (*MsgWaitForMultipleObjects)( DWORD, HANDLE *, BOOL, DWORD, DWORD );
40 HWND WINAPI (*WindowFromDC)( HDC );
41 INT WINAPI (*MessageBoxA)( HWND, LPCSTR, LPCSTR, UINT );
42 INT WINAPI (*MessageBoxW)( HWND, LPCWSTR, LPCWSTR, UINT );
43 } CALLOUT_TABLE;
45 extern CALLOUT_TABLE Callout;
48 typedef struct {
49 struct _DOSTASK* WINAPI (*Current)( void );
50 struct _DOSTASK* WINAPI (*LoadDPMI)( void );
51 void WINAPI (*LoadDosExe)( LPCSTR filename, HANDLE hFile );
52 BOOL WINAPI (*Exec)( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk );
53 void WINAPI (*Exit)( CONTEXT86 *context, BOOL cs_psp, WORD retval );
54 int WINAPI (*Enter)( CONTEXT86 *context );
55 void WINAPI (*Wait)( int read_pipe, HANDLE hObject );
56 void WINAPI (*QueueEvent)( int irq, int priority, void (*relay)(CONTEXT86*,void*), void *data );
57 void WINAPI (*OutPIC)( WORD port, BYTE val );
58 void WINAPI (*SetTimer)( unsigned ticks );
59 unsigned WINAPI (*GetTimer)( void );
60 } DOSVM_TABLE;
62 extern DOSVM_TABLE Dosvm;
65 #include "pshpack1.h"
67 typedef struct tagTHUNK
69 BYTE popl_eax; /* 0x58 popl %eax (return address)*/
70 BYTE pushl_func; /* 0x68 pushl $proc */
71 FARPROC16 proc WINE_PACKED;
72 BYTE pushl_eax; /* 0x50 pushl %eax */
73 BYTE jmp; /* 0xe9 jmp relay (relative jump)*/
74 RELAY relay WINE_PACKED;
75 struct tagTHUNK *next WINE_PACKED;
76 DWORD magic;
77 } THUNK;
79 #include "poppack.h"
81 #define CALLTO16_THUNK_MAGIC 0x54484e4b /* "THNK" */
83 #define DECL_THUNK(aname,aproc,arelay) \
84 THUNK aname; \
85 aname.popl_eax = 0x58; \
86 aname.pushl_func = 0x68; \
87 aname.proc = (FARPROC16) (aproc); \
88 aname.pushl_eax = 0x50; \
89 aname.jmp = 0xe9; \
90 aname.relay = (RELAY)((char *)(arelay) - (char *)(&(aname).next)); \
91 aname.next = NULL; \
92 aname.magic = CALLTO16_THUNK_MAGIC;
94 #endif /* __WINE_CALLBACK_H */