1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or https://opensource.org/licenses/CDDL-1.0. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _IA32_SYS_ASM_LINKAGE_H 28 #define _IA32_SYS_ASM_LINKAGE_H 29 30 #define RET ret 31 32 /* Tell compiler to call assembler like Unix */ 33 #undef ASMABI 34 #define ASMABI __attribute__((sysv_abi)) 35 36 #define ENDBR 37 38 #define SECTION_TEXT .text 39 #define SECTION_STATIC .section .rodata 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif 44 45 #ifdef _ASM /* The remainder of this file is only for assembly files */ 46 47 48 /* 49 * make annoying differences in assembler syntax go away 50 */ 51 52 /* 53 * D16 and A16 are used to insert instructions prefixes; the 54 * macros help the assembler code be slightly more portable. 55 */ 56 #if !defined(__GNUC_AS__) 57 /* 58 * /usr/ccs/bin/as prefixes are parsed as separate instructions 59 */ 60 #define D16 data16; 61 #define A16 addr16; 62 63 /* 64 * (There are some weird constructs in constant expressions) 65 */ 66 #define _CONST(const) [const] 67 #define _BITNOT(const) -1!_CONST(const) 68 #define _MUL(a, b) _CONST(a \* b) 69 70 #else 71 /* 72 * Why not use the 'data16' and 'addr16' prefixes .. well, the 73 * assembler doesn't quite believe in real mode, and thus argues with 74 * us about what we're trying to do. 75 */ 76 #define D16 .byte 0x66; 77 #define A16 .byte 0x67; 78 79 #define _CONST(const) (const) 80 #define _BITNOT(const) ~_CONST(const) 81 #define _MUL(a, b) _CONST(a * b) 82 83 #endif 84 85 /* 86 * C pointers are different sizes between i386 and amd64. 87 * These constants can be used to compute offsets into pointer arrays. 88 */ 89 #if defined(__amd64) 90 #define CLONGSHIFT 3 91 #define CLONGSIZE 8 92 #define CLONGMASK 7 93 #elif defined(__i386) 94 #define CLONGSHIFT 2 95 #define CLONGSIZE 4 96 #define CLONGMASK 3 97 #endif 98 99 /* 100 * Since we know we're either ILP32 or LP64 .. 101 */ 102 #define CPTRSHIFT CLONGSHIFT 103 #define CPTRSIZE CLONGSIZE 104 #define CPTRMASK CLONGMASK 105 106 #if CPTRSIZE != (1 << CPTRSHIFT) || CLONGSIZE != (1 << CLONGSHIFT) 107 #error "inconsistent shift constants" 108 #endif 109 110 #if CPTRMASK != (CPTRSIZE - 1) || CLONGMASK != (CLONGSIZE - 1) 111 #error "inconsistent mask constants" 112 #endif 113 114 #define ASM_ENTRY_ALIGN 16 115 116 /* 117 * SSE register alignment and save areas 118 */ 119 120 #define XMM_SIZE 16 121 #define XMM_ALIGN 16 122 123 /* 124 * ENTRY provides the standard procedure entry code and an easy way to 125 * insert the calls to mcount for profiling. ENTRY_NP is identical, but 126 * never calls mcount. 127 */ 128 #define ENTRY(x) \ 129 .text; \ 130 .balign ASM_ENTRY_ALIGN; \ 131 .globl x; \ 132 x: MCOUNT(x) 133 134 #define ENTRY_NP(x) \ 135 .text; \ 136 .balign ASM_ENTRY_ALIGN; \ 137 .globl x; \ 138 x: 139 140 #define ENTRY_ALIGN(x, a) \ 141 .text; \ 142 .balign a; \ 143 .globl x; \ 144 x: 145 146 /* 147 * ENTRY2 is identical to ENTRY but provides two labels for the entry point. 148 */ 149 #define ENTRY2(x, y) \ 150 .text; \ 151 .balign ASM_ENTRY_ALIGN; \ 152 .globl x, y; \ 153 x:; \ 154 y: MCOUNT(x) 155 156 #define ENTRY_NP2(x, y) \ 157 .text; \ 158 .balign ASM_ENTRY_ALIGN; \ 159 .globl x, y; \ 160 x:; \ 161 y: 162 163 164 /* 165 * SET_SIZE trails a function and set the size for the ELF symbol table. 166 */ 167 #define SET_SIZE(x) 168 169 #define SET_OBJ(x) 170 171 172 #endif /* _ASM */ 173 174 #ifdef __cplusplus 175 } 176 #endif 177 178 #endif /* _IA32_SYS_ASM_LINKAGE_H */ 179