github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/include/jit/jit-arch-x86.h (about)

     1  /*
     2   * jit-arch-x86.h - Architecture-specific definitions.
     3   *
     4   * Copyright (C) 2006  Southern Storm Software, Pty Ltd.
     5   *
     6   * The libjit library is free software: you can redistribute it and/or
     7   * modify it under the terms of the GNU Lesser General Public License
     8   * as published by the Free Software Foundation, either version 2.1 of
     9   * the License, or (at your option) any later version.
    10   *
    11   * The libjit 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.
    15   *
    16   * You should have received a copy of the GNU Lesser General Public
    17   * License along with the libjit library.  If not, see
    18   * <http://www.gnu.org/licenses/>.
    19   */
    20  
    21  #ifndef	_JIT_ARCH_X86_H
    22  #define	_JIT_ARCH_X86_H
    23  
    24  /*
    25   * If defined _JIT_ARCH_GET_CURRENT_FRAME() macro assigns the current frame
    26   * pointer to the supplied argument that has to be a void pointer.
    27   */
    28  #if defined(__GNUC__)
    29  #define _JIT_ARCH_GET_CURRENT_FRAME(f)		\
    30  	do {					\
    31  		register void *__f asm("ebp");	\
    32  		f = __f;			\
    33  	} while(0)
    34  #elif defined(_MSC_VER) && defined(_M_IX86)
    35  #define	_JIT_ARCH_GET_CURRENT_FRAME(f)		\
    36  	do {					\
    37  		void *__ptr;			\
    38  		__asm				\
    39  		{				\
    40  			__asm mov dword ptr __ptr, ebp	\
    41  		}				\
    42  		(f) = __ptr;			\
    43  	} while(0)
    44  #else
    45  #undef _JIT_ARCH_GET_CURRENT_FRAME
    46  #endif
    47  
    48  #endif /* _JIT_ARCH_X86_H */