2003-08-30 00:23:42 +02:00
|
|
|
/*
|
|
|
|
* Wine portability routines
|
|
|
|
*
|
|
|
|
* Copyright 2000 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-08-30 00:23:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
2020-01-29 10:48:39 +01:00
|
|
|
#include "wine/asm.h"
|
|
|
|
|
|
|
|
#ifdef __ASM_OBSOLETE
|
2003-08-30 00:23:42 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
2020-11-29 21:21:49 +01:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <windef.h>
|
2016-02-18 06:10:26 +01:00
|
|
|
|
2009-07-04 11:36:44 +02:00
|
|
|
/* no longer used, for backwards compatibility only */
|
|
|
|
struct wine_pthread_functions;
|
|
|
|
static void *pthread_functions[8];
|
2003-11-06 00:31:11 +01:00
|
|
|
|
2003-10-14 03:27:31 +02:00
|
|
|
/***********************************************************************
|
2005-09-03 17:11:29 +02:00
|
|
|
* wine_pthread_get_functions
|
2003-10-14 03:27:31 +02:00
|
|
|
*/
|
2020-01-29 10:48:39 +01:00
|
|
|
void wine_pthread_get_functions_obsolete( struct wine_pthread_functions *functions, size_t size )
|
2003-10-14 03:27:31 +02:00
|
|
|
{
|
2005-09-03 17:11:29 +02:00
|
|
|
memcpy( functions, &pthread_functions, min( size, sizeof(pthread_functions) ));
|
2003-10-14 03:27:31 +02:00
|
|
|
}
|
|
|
|
|
2003-11-06 00:31:11 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2005-09-03 17:11:29 +02:00
|
|
|
* wine_pthread_set_functions
|
2003-11-06 00:31:11 +01:00
|
|
|
*/
|
2020-01-29 10:48:39 +01:00
|
|
|
void wine_pthread_set_functions_obsolete( const struct wine_pthread_functions *functions, size_t size )
|
2003-11-06 00:31:11 +01:00
|
|
|
{
|
2005-09-03 17:11:29 +02:00
|
|
|
memcpy( &pthread_functions, functions, min( size, sizeof(pthread_functions) ));
|
2003-11-06 00:31:11 +01:00
|
|
|
}
|
2003-10-14 03:27:31 +02:00
|
|
|
|
|
|
|
|
2008-03-26 15:38:00 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* wine_call_on_stack
|
|
|
|
*
|
|
|
|
* Switch to the specified stack to call the function and return.
|
|
|
|
*/
|
2009-05-15 15:51:53 +02:00
|
|
|
|
2020-01-29 10:48:39 +01:00
|
|
|
extern int wine_call_on_stack_obsolete( int (*func)(void *), void *arg, void *stack );
|
2008-03-26 15:38:00 +01:00
|
|
|
#if defined(__i386__) && defined(__GNUC__)
|
2020-01-29 10:48:39 +01:00
|
|
|
__ASM_GLOBAL_FUNC( wine_call_on_stack_obsolete,
|
2008-03-26 15:38:00 +01:00
|
|
|
"pushl %ebp\n\t"
|
2009-06-25 11:54:02 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
|
2008-03-26 15:38:00 +01:00
|
|
|
"pushl %esi\n\t"
|
2009-06-25 11:54:02 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %esi,0\n\t")
|
|
|
|
"movl %esp,%esi\n\t"
|
|
|
|
__ASM_CFI(".cfi_def_cfa_register %esi\n\t")
|
2008-03-26 15:38:00 +01:00
|
|
|
"movl 12(%esp),%ecx\n\t" /* func */
|
|
|
|
"movl 16(%esp),%edx\n\t" /* arg */
|
2009-06-25 11:54:02 +02:00
|
|
|
"movl 20(%esp),%eax\n\t" /* stack */
|
|
|
|
"andl $~15,%eax\n\t"
|
|
|
|
"subl $12,%eax\n\t"
|
|
|
|
"movl %eax,%esp\n\t"
|
2008-03-26 15:38:00 +01:00
|
|
|
"pushl %edx\n\t"
|
|
|
|
"xorl %ebp,%ebp\n\t"
|
|
|
|
"call *%ecx\n\t"
|
|
|
|
"movl %esi,%esp\n\t"
|
|
|
|
"popl %esi\n\t"
|
2009-06-25 11:54:02 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset -4\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %esi\n\t")
|
2008-03-26 15:38:00 +01:00
|
|
|
"popl %ebp\n\t"
|
2009-06-25 11:54:02 +02:00
|
|
|
__ASM_CFI(".cfi_def_cfa %esp,4\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %ebp\n\t")
|
2008-03-26 15:38:00 +01:00
|
|
|
"ret" )
|
|
|
|
#elif defined(__x86_64__) && defined(__GNUC__)
|
2020-01-29 10:48:39 +01:00
|
|
|
__ASM_GLOBAL_FUNC( wine_call_on_stack_obsolete,
|
2008-03-26 15:38:00 +01:00
|
|
|
"pushq %rbp\n\t"
|
2010-04-12 12:37:35 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset 8\n\t")
|
|
|
|
__ASM_CFI(".cfi_rel_offset %rbp,0\n\t")
|
2009-06-16 14:26:20 +02:00
|
|
|
"movq %rsp,%rbp\n\t"
|
2010-04-12 12:37:35 +02:00
|
|
|
__ASM_CFI(".cfi_def_cfa_register %rbp\n\t")
|
2008-03-26 15:38:00 +01:00
|
|
|
"movq %rdi,%rax\n\t" /* func */
|
|
|
|
"movq %rsi,%rdi\n\t" /* arg */
|
|
|
|
"andq $~15,%rdx\n\t" /* stack */
|
|
|
|
"movq %rdx,%rsp\n\t"
|
|
|
|
"callq *%rax\n\t" /* call func */
|
2009-06-16 14:26:20 +02:00
|
|
|
"movq %rbp,%rsp\n\t"
|
2010-04-12 12:37:35 +02:00
|
|
|
__ASM_CFI(".cfi_def_cfa_register %rsp\n\t")
|
2008-03-26 15:38:00 +01:00
|
|
|
"popq %rbp\n\t"
|
2010-04-12 12:37:35 +02:00
|
|
|
__ASM_CFI(".cfi_adjust_cfa_offset -8\n\t")
|
|
|
|
__ASM_CFI(".cfi_same_value %rbp\n\t")
|
2008-03-26 15:38:00 +01:00
|
|
|
"ret")
|
2003-08-30 00:23:42 +02:00
|
|
|
#endif
|
2020-01-29 10:48:39 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* wine_switch_to_stack
|
|
|
|
*
|
|
|
|
* Switch to the specified stack and call the function.
|
|
|
|
*/
|
|
|
|
void DECLSPEC_NORETURN wine_switch_to_stack_obsolete( void (*func)(void *), void *arg, void *stack )
|
|
|
|
{
|
|
|
|
wine_call_on_stack_obsolete( (int (*)(void *))func, arg, stack );
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
__ASM_OBSOLETE(wine_pthread_get_functions);
|
|
|
|
__ASM_OBSOLETE(wine_pthread_set_functions);
|
|
|
|
__ASM_OBSOLETE(wine_call_on_stack);
|
|
|
|
__ASM_OBSOLETE(wine_switch_to_stack);
|
|
|
|
|
|
|
|
#endif /* __ASM_OBSOLETE */
|