Rename patches to -akaros instead of -ros
[akaros.git] / tools / compilers / gcc-glibc / glibc-2.14.1-akaros / sysdeps / akaros / i386 / sysdep.h
1 /* Assembler macros for i386.
2    Copyright (C) 1991-93,95,96,98,2002,2003,2005,2006
3    Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    The GNU C 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 GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #ifndef _AKAROS_I386_SYSDEP_H
22 #define _AKAROS_I386_SYSDEP_H
23
24 #undef __i686 /* Having __i686 defined messes with SETUP_PIC_REG et al. */
25
26 #include <sysdeps/generic/sysdep.h>
27
28 #ifdef __ASSEMBLER__
29 # define PTR_MANGLE(a)
30 # define PTR_DEMANGLE(a)
31 #else
32 # define PTR_MANGLE(a) (a)
33 # define PTR_DEMANGLE(a) (a)
34 #endif
35
36 #ifdef  __ASSEMBLER__
37
38 /* Syntactic details of assembler.  */
39
40 #ifdef HAVE_ELF
41
42 /* ELF uses byte-counts for .align, most others use log2 of count of bytes.  */
43 #define ALIGNARG(log2) 1<<log2
44 /* For ELF we need the `.type' directive to make shared libs work right.  */
45 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
46 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
47
48 /* In ELF C symbols are asm symbols.  */
49 #undef  NO_UNDERSCORES
50 #define NO_UNDERSCORES
51
52 #else
53
54 #define ALIGNARG(log2) log2
55 #define ASM_TYPE_DIRECTIVE(name,type)   /* Nothing is specified.  */
56 #define ASM_SIZE_DIRECTIVE(name)        /* Nothing is specified.  */
57
58 #endif
59
60
61 /* Define an entry point visible from C.
62
63    There is currently a bug in gdb which prevents us from specifying
64    incomplete stabs information.  Fake some entries here which specify
65    the current source file.  */
66 #define ENTRY(name)                                                           \
67   STABS_CURRENT_FILE1("")                                                     \
68   STABS_CURRENT_FILE(name)                                                    \
69   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);                                   \
70   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)                          \
71   .align ALIGNARG(4);                                                         \
72   STABS_FUN(name)                                                             \
73   C_LABEL(name)                                                               \
74   cfi_startproc;                                                              \
75   CALL_MCOUNT
76
77 #undef  END
78 #define END(name)                                                             \
79   cfi_endproc;                                                                \
80   ASM_SIZE_DIRECTIVE(name)                                                    \
81   STABS_FUN_END(name)
82
83 #ifdef HAVE_CPP_ASM_DEBUGINFO
84 /* Disable that goop, because we just pass -g through to the assembler
85    and it generates proper line number information directly.  */
86 # define STABS_CURRENT_FILE1(name)
87 # define STABS_CURRENT_FILE(name)
88 # define STABS_FUN(name)
89 # define STABS_FUN_END(name)
90 #else
91 /* Remove the following two lines once the gdb bug is fixed.  */
92 #define STABS_CURRENT_FILE(name)                                              \
93   STABS_CURRENT_FILE1 (#name)
94 #define STABS_CURRENT_FILE1(name)                                             \
95   1: .stabs name,100,0,0,1b;
96 /* Emit stabs definition lines.  We use F(0,1) and define t(0,1) as `int',
97    the same way gcc does it.  */
98 #define STABS_FUN(name) STABS_FUN2(name, name##:F(0,1))
99 #define STABS_FUN2(name, namestr)                                             \
100   .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0;               \
101   .stabs #namestr,36,0,0,name;
102 #define STABS_FUN_END(name)                                                   \
103   1: .stabs "",36,0,0,1b-name;
104 #endif
105
106 /* If compiled for profiling, call `mcount' at the start of each function.  */
107 #ifdef  PROF
108 /* The mcount code relies on a normal frame pointer being on the stack
109    to locate our caller, so push one just for its benefit.  */
110 #define CALL_MCOUNT \
111   pushl %ebp; cfi_adjust_cfa_offset (4); movl %esp, %ebp; \
112   cfi_def_cfa_register (ebp); call JUMPTARGET(mcount); \
113   popl %ebp; cfi_def_cfa (esp, 4);
114 #else
115 #define CALL_MCOUNT             /* Do nothing.  */
116 #endif
117
118 #ifdef  NO_UNDERSCORES
119 /* Since C identifiers are not normally prefixed with an underscore
120    on this system, the asm identifier `syscall_error' intrudes on the
121    C name space.  Make sure we use an innocuous name.  */
122 #define syscall_error   __syscall_error
123 #define mcount          _mcount
124 #endif
125
126 #define PSEUDO(name, syscall_name, args)                                      \
127   .globl syscall_error;                                                       \
128 lose: SYSCALL_PIC_SETUP                                                       \
129   jmp JUMPTARGET(syscall_error);                                              \
130   ENTRY (name)                                                                \
131   DO_CALL (syscall_name, args);                                               \
132   jb lose
133
134 #undef  PSEUDO_END
135 #define PSEUDO_END(name)                                                      \
136   END (name)
137
138 #undef JUMPTARGET
139 #ifdef PIC
140 #define JUMPTARGET(name)        name##@PLT
141 #define SYSCALL_PIC_SETUP \
142     pushl %ebx;                                                               \
143     cfi_adjust_cfa_offset (4);                                                \
144     call 0f;                                                                  \
145 0:  popl %ebx;                                                                \
146     cfi_adjust_cfa_offset (-4);                                               \
147     addl $_GLOBAL_OFFSET_TABLE+[.-0b], %ebx;
148
149 # define SETUP_PIC_REG(reg) \
150   .ifndef __i686.get_pc_thunk.reg;                                            \
151   .section .gnu.linkonce.t.__i686.get_pc_thunk.reg,"ax",@progbits;            \
152   .globl __i686.get_pc_thunk.reg;                                             \
153   .hidden __i686.get_pc_thunk.reg;                                            \
154   .type __i686.get_pc_thunk.reg,@function;                                    \
155 __i686.get_pc_thunk.reg:                                                      \
156   movl (%esp), %e##reg;                                                       \
157   ret;                                                                        \
158   .size __i686.get_pc_thunk.reg, . - __i686.get_pc_thunk.reg;                 \
159   .previous;                                                                  \
160   .endif;                                                                     \
161   call __i686.get_pc_thunk.reg
162
163 # define LOAD_PIC_REG(reg) \
164   SETUP_PIC_REG(reg); addl $_GLOBAL_OFFSET_TABLE_, %e##reg
165
166 #else
167 #define JUMPTARGET(name)        name
168 #define SYSCALL_PIC_SETUP       /* Nothing.  */
169 #endif
170
171 /* Local label name for asm code. */
172 #ifndef L
173 #ifdef HAVE_ELF
174 #define L(name)         .L##name
175 #else
176 #define L(name)         name
177 #endif
178 #endif
179
180 #endif  /* __ASSEMBLER__ */
181
182 #endif /* _AKAROS_I386_SYSDEP_H */