dinput/tests: Support test IOCTLs on the bus control interface.
[wine.git] / libs / wine / port.c
blobb019e1d2fd4f890eba9c531d3fc24990a93a01c4
1 /*
2 * Wine portability routines
4 * Copyright 2000 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/asm.h"
24 #ifdef __ASM_OBSOLETE
26 #include <stdlib.h>
27 #include <string.h>
28 #include <sys/types.h>
29 #include <stdarg.h>
30 #include <windef.h>
32 /* no longer used, for backwards compatibility only */
33 struct wine_pthread_functions;
34 static void *pthread_functions[8];
36 /***********************************************************************
37 * wine_pthread_get_functions
39 void wine_pthread_get_functions_obsolete( struct wine_pthread_functions *functions, size_t size )
41 memcpy( functions, &pthread_functions, min( size, sizeof(pthread_functions) ));
45 /***********************************************************************
46 * wine_pthread_set_functions
48 void wine_pthread_set_functions_obsolete( const struct wine_pthread_functions *functions, size_t size )
50 memcpy( &pthread_functions, functions, min( size, sizeof(pthread_functions) ));
54 /***********************************************************************
55 * wine_call_on_stack
57 * Switch to the specified stack to call the function and return.
60 extern int wine_call_on_stack_obsolete( int (*func)(void *), void *arg, void *stack );
61 #if defined(__i386__) && defined(__GNUC__)
62 __ASM_GLOBAL_FUNC( wine_call_on_stack_obsolete,
63 "pushl %ebp\n\t"
64 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
65 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
66 "pushl %esi\n\t"
67 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
68 __ASM_CFI(".cfi_rel_offset %esi,0\n\t")
69 "movl %esp,%esi\n\t"
70 __ASM_CFI(".cfi_def_cfa_register %esi\n\t")
71 "movl 12(%esp),%ecx\n\t" /* func */
72 "movl 16(%esp),%edx\n\t" /* arg */
73 "movl 20(%esp),%eax\n\t" /* stack */
74 "andl $~15,%eax\n\t"
75 "subl $12,%eax\n\t"
76 "movl %eax,%esp\n\t"
77 "pushl %edx\n\t"
78 "xorl %ebp,%ebp\n\t"
79 "call *%ecx\n\t"
80 "movl %esi,%esp\n\t"
81 "popl %esi\n\t"
82 __ASM_CFI(".cfi_adjust_cfa_offset -4\n\t")
83 __ASM_CFI(".cfi_same_value %esi\n\t")
84 "popl %ebp\n\t"
85 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
86 __ASM_CFI(".cfi_same_value %ebp\n\t")
87 "ret" )
88 #elif defined(__x86_64__) && defined(__GNUC__)
89 __ASM_GLOBAL_FUNC( wine_call_on_stack_obsolete,
90 "pushq %rbp\n\t"
91 __ASM_CFI(".cfi_adjust_cfa_offset 8\n\t")
92 __ASM_CFI(".cfi_rel_offset %rbp,0\n\t")
93 "movq %rsp,%rbp\n\t"
94 __ASM_CFI(".cfi_def_cfa_register %rbp\n\t")
95 "movq %rdi,%rax\n\t" /* func */
96 "movq %rsi,%rdi\n\t" /* arg */
97 "andq $~15,%rdx\n\t" /* stack */
98 "movq %rdx,%rsp\n\t"
99 "callq *%rax\n\t" /* call func */
100 "movq %rbp,%rsp\n\t"
101 __ASM_CFI(".cfi_def_cfa_register %rsp\n\t")
102 "popq %rbp\n\t"
103 __ASM_CFI(".cfi_adjust_cfa_offset -8\n\t")
104 __ASM_CFI(".cfi_same_value %rbp\n\t")
105 "ret")
106 #endif
108 /***********************************************************************
109 * wine_switch_to_stack
111 * Switch to the specified stack and call the function.
113 void DECLSPEC_NORETURN wine_switch_to_stack_obsolete( void (*func)(void *), void *arg, void *stack )
115 wine_call_on_stack_obsolete( (int (*)(void *))func, arg, stack );
116 abort();
119 __ASM_OBSOLETE(wine_pthread_get_functions);
120 __ASM_OBSOLETE(wine_pthread_set_functions);
121 __ASM_OBSOLETE(wine_call_on_stack);
122 __ASM_OBSOLETE(wine_switch_to_stack);
124 #endif /* __ASM_OBSOLETE */