af062818b47340eef15700d2f0211576ba3506eevboxsync * Wine portability routines
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright 2000 Alexandre Julliard
af062818b47340eef15700d2f0211576ba3506eevboxsync * This library is free software; you can redistribute it and/or
af062818b47340eef15700d2f0211576ba3506eevboxsync * modify it under the terms of the GNU Lesser General Public
af062818b47340eef15700d2f0211576ba3506eevboxsync * License as published by the Free Software Foundation; either
af062818b47340eef15700d2f0211576ba3506eevboxsync * version 2.1 of the License, or (at your option) any later version.
af062818b47340eef15700d2f0211576ba3506eevboxsync * This library is distributed in the hope that it will be useful,
af062818b47340eef15700d2f0211576ba3506eevboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
af062818b47340eef15700d2f0211576ba3506eevboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * Lesser General Public License for more details.
af062818b47340eef15700d2f0211576ba3506eevboxsync * You should have received a copy of the GNU Lesser General Public
af062818b47340eef15700d2f0211576ba3506eevboxsync * License along with this library; if not, write to the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync * a choice of LGPL license versions is made available with the language indicating
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync * that LGPLv2 or any later version may be used, or where a choice of which version
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync * of the LGPL is applied is otherwise unspecified.
040b4a09341f574825386333398110f4db3e1e51vboxsync/* no longer used, for backwards compatibility only */
af062818b47340eef15700d2f0211576ba3506eevboxsync/***********************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync * wine_pthread_get_functions
af062818b47340eef15700d2f0211576ba3506eevboxsyncvoid wine_pthread_get_functions( struct wine_pthread_functions *functions, size_t size )
af062818b47340eef15700d2f0211576ba3506eevboxsync memcpy( functions, &pthread_functions, min( size, sizeof(pthread_functions) ));
af062818b47340eef15700d2f0211576ba3506eevboxsync/***********************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync * wine_pthread_set_functions
af062818b47340eef15700d2f0211576ba3506eevboxsyncvoid wine_pthread_set_functions( const struct wine_pthread_functions *functions, size_t size )
af062818b47340eef15700d2f0211576ba3506eevboxsync memcpy( &pthread_functions, functions, min( size, sizeof(pthread_functions) ));
af062818b47340eef15700d2f0211576ba3506eevboxsync/***********************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync * wine_switch_to_stack
af062818b47340eef15700d2f0211576ba3506eevboxsync * Switch to the specified stack and call the function.
af062818b47340eef15700d2f0211576ba3506eevboxsyncvoid DECLSPEC_NORETURN wine_switch_to_stack( void (*func)(void *), void *arg, void *stack )
af062818b47340eef15700d2f0211576ba3506eevboxsync wine_call_on_stack( (int (*)(void *))func, arg, stack );
af062818b47340eef15700d2f0211576ba3506eevboxsync/***********************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync * wine_call_on_stack
af062818b47340eef15700d2f0211576ba3506eevboxsync * Switch to the specified stack to call the function and return.
af062818b47340eef15700d2f0211576ba3506eevboxsync "pushl %ebp\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "pushl %esi\n\t"
040b4a09341f574825386333398110f4db3e1e51vboxsync "movl %esp,%esi\n\t"
040b4a09341f574825386333398110f4db3e1e51vboxsync "andl $~15,%eax\n\t"
040b4a09341f574825386333398110f4db3e1e51vboxsync "subl $12,%eax\n\t"
040b4a09341f574825386333398110f4db3e1e51vboxsync "movl %eax,%esp\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "pushl %edx\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "xorl %ebp,%ebp\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "call *%ecx\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "movl %esi,%esp\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "popl %esi\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "popl %ebp\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync__declspec(naked) int wine_call_on_stack( int (*func)(void *), void *arg, void *stack )
af062818b47340eef15700d2f0211576ba3506eevboxsync "pushq %rbp\n\t"
040b4a09341f574825386333398110f4db3e1e51vboxsync "movq %rsp,%rbp\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "movq %rdx,%rsp\n\t"
040b4a09341f574825386333398110f4db3e1e51vboxsync "movq %rbp,%rsp\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "popq %rbp\n\t"
af062818b47340eef15700d2f0211576ba3506eevboxsync "subi 5, 5, 16\n\t" /* reserve space on new stack */
af062818b47340eef15700d2f0211576ba3506eevboxsync "stwu 1, -16(1)\n\t" /* create a frame for this function */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync "str r14, [r13, #4]\n\t" /* save return address on stack */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync "sub r2, r2, #16\n\t" /* reserve space on new stack */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync "sub r13, r13, #16\n\t" /* create a frame for this function */
5112e32d7072e280613921c982a6672f2c859cf3vboxsync "ldr r15, [r13, #4]") /* fetch return address and return */