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