]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/s390/s390-32/sysdep.h
Replace FSF snail mail address with URLs.
[thirdparty/glibc.git] / sysdeps / s390 / s390-32 / sysdep.h
1 /* Assembler macros for s390.
2 Copyright (C) 2000, 2001, 2003, 2012 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
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, see
18 <http://www.gnu.org/licenses/>. */
19
20 #include <sysdeps/generic/sysdep.h>
21
22 #ifdef __ASSEMBLER__
23
24 /* Syntactic details of assembler. */
25
26 /* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
27 #define ALIGNARG(log2) 1<<log2
28 /* For ELF we need the `.type' directive to make shared libs work right. */
29 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
30 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
31
32
33 /* Define an entry point visible from C. */
34 #define ENTRY(name) \
35 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
36 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
37 .align ALIGNARG(2); \
38 C_LABEL(name) \
39 cfi_startproc; \
40 CALL_MCOUNT
41
42 #undef END
43 #define END(name) \
44 cfi_endproc; \
45 ASM_SIZE_DIRECTIVE(name) \
46
47 /* If compiled for profiling, call `mcount' at the start of each function. */
48 #ifdef PROF
49 #ifdef PIC
50 #define CALL_MCOUNT \
51 lr 0,14 ; bras 14,.+12 ; .long _GLOBAL_OFFSET_TABLE_ - . ; .long 0f-. ; \
52 lr 1,14 ; al 1,4(14) ; al 14,0(14) ; l 14,_mcount@GOT(14) ; \
53 basr 14,14 ; lr 14,0 ; .data ; .align 4 ; 0: .long 0 ; .text ;
54 #else
55 #define CALL_MCOUNT \
56 lr 0,14 ; bras 14,.+12 ; .long _mcount ; .long 0f ; \
57 l 1,4(14) ; l 14,0(14) ; basr 14,14 ; lr 14,0 ; \
58 .data ; .align 4 ; 0: .long 0 ; .text ;
59 #endif
60 #else
61 #define CALL_MCOUNT /* Do nothing. */
62 #endif
63
64 /* Since C identifiers are not normally prefixed with an underscore
65 on this system, the asm identifier `syscall_error' intrudes on the
66 C name space. Make sure we use an innocuous name. */
67 #define syscall_error __syscall_error
68 #define mcount _mcount
69
70 #define PSEUDO(name, syscall_name, args) \
71 lose: SYSCALL_PIC_SETUP \
72 basr %r1,0; \
73 0: al %r1,1f-0b(%r1); \
74 br %r1; \
75 1: .long JUMPTARGET(syscall_error) - 0b; \
76 .globl syscall_error; \
77 ENTRY (name) \
78 DO_CALL (syscall_name, args); \
79 jm lose
80
81 #undef PSEUDO_END
82 #define PSEUDO_END(name) \
83 END (name)
84
85 #undef JUMPTARGET
86 #ifdef PIC
87 #define JUMPTARGET(name) name##@PLT
88 #define SYSCALL_PIC_SETUP \
89 bras %r12,1f \
90 0: .long _GLOBAL_OFFSET_TABLE_-0b \
91 1: al %r12,0(%r12)
92 #else
93 #define JUMPTARGET(name) name
94 #define SYSCALL_PIC_SETUP /* Nothing. */
95 #endif
96
97 /* Local label name for asm code. */
98 #ifndef L
99 #define L(name) .L##name
100 #endif
101
102 #endif /* __ASSEMBLER__ */