/ src / entry_pt_macros.h
entry_pt_macros.h
 1  /*
 2   * Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved.
 3   *
 4   * Redistribution and use in source and binary forms, with or without modification,
 5   * are permitted provided that the following conditions are met:
 6   * 1. Redistributions of source code must retain the above copyright notice,
 7   *    this list of conditions and the following disclaimer.
 8   * 2. Redistributions in binary form must reproduce the above copyright notice,
 9   *    this list of conditions and the following disclaimer in the documentation
10   *    and/or other materials provided with the distribution.
11   * 3. Neither the name of the copyright holder nor the names of its contributors
12   *    may be used to endorse or promote products derived from this software without
13   *    specific prior written permission.
14   *
15   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18   * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20   * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21   * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24   * POSSIBILITY OF SUCH DAMAGE.
25   *
26   */
27  
28  #ifndef __ENTRY_PT_MACROS_H__
29  #define __ENTRY_PT_MACROS_H__
30  
31  #include <libm/types.h>
32  
33  #define MK_FN_NAME(fn)				\
34  	STRINGIFY(FN_PROTOTYPE(fn))
35  
36  /*
37   * This should gnerate something like this
38   * -------------
39   * #define fname_expf FN_PROTOTYPE(expf)
40   * .p2align 4
41   * .globl fname_expf
42   * .type fname_expf,@function
43   * fname_expf:
44   * mov g_amd_libm_ep_expf@GOTPCREL(%rip), %rax
45   * jmp *(%rax)
46   * -----------
47   */
48  #define LIBM_DECL_FN_MAP(fn)						\
49  	asm (								\
50  	"\n\t"".p2align 4"						\
51  	"\n\t"".globl " MK_FN_NAME(fn)					\
52  	"\n\t"".type " STRINGIFY(FN_PROTOTYPE(fn)) " ,@function"	\
53  	"\n\t" MK_FN_NAME(fn) " :"					\
54  	"\n\t" "mov " STRINGIFY(G_ENTRY_PT_ASM(fn)) "@GOTPCREL(%rip), %rax"	\
55  	"\n\t" "jmp *(%rax)"						\
56  		);
57  
58  
59  #define WEAK_LIBM_ALIAS(x, y)					\
60  	asm("\n\t"".weak " STRINGIFY(x)				\
61  	    "\n\t"".set " STRINGIFY(x) ", " STRINGIFY(y)	\
62  	    "\n\t");
63  
64  #endif /* __ENTRY_PT_MACROS_H__ */
65