2.9
[glibc/nacl-glibc.git] / sysdeps / s390 / s390-32 / sysdep.h
blobf2d5bada88d0ce283728c7da149b0abecf62d2e4
1 /* Assembler macros for s390.
2 Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
3 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
4 This file is part of the GNU C Library.
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.
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.
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. */
21 #include <sysdeps/generic/sysdep.h>
23 #ifdef __ASSEMBLER__
25 /* Syntactic details of assembler. */
27 #ifdef HAVE_ELF
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;
33 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
35 /* In ELF C symbols are asm symbols. */
36 #undef NO_UNDERSCORES
37 #define NO_UNDERSCORES
39 #else
41 #define ALIGNARG(log2) log2
42 #define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */
43 #define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */
45 #endif
48 /* Define an entry point visible from C. */
49 #define ENTRY(name) \
50 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
51 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
52 .align ALIGNARG(2); \
53 C_LABEL(name) \
54 cfi_startproc; \
55 CALL_MCOUNT
57 #undef END
58 #define END(name) \
59 cfi_endproc; \
60 ASM_SIZE_DIRECTIVE(name) \
62 /* If compiled for profiling, call `mcount' at the start of each function. */
63 #ifdef PROF
64 #ifdef PIC
65 #define CALL_MCOUNT \
66 lr 0,14 ; bras 14,.+12 ; .long _GLOBAL_OFFSET_TABLE_ - . ; .long 0f-. ; \
67 lr 1,14 ; al 1,4(14) ; al 14,0(14) ; l 14,_mcount@GOT(14) ; \
68 basr 14,14 ; lr 14,0 ; .data ; .align 4 ; 0: .long 0 ; .text ;
69 #else
70 #define CALL_MCOUNT \
71 lr 0,14 ; bras 14,.+12 ; .long _mcount ; .long 0f ; \
72 l 1,4(14) ; l 14,0(14) ; basr 14,14 ; lr 14,0 ; \
73 .data ; .align 4 ; 0: .long 0 ; .text ;
74 #endif
75 #else
76 #define CALL_MCOUNT /* Do nothing. */
77 #endif
79 #ifdef NO_UNDERSCORES
80 /* Since C identifiers are not normally prefixed with an underscore
81 on this system, the asm identifier `syscall_error' intrudes on the
82 C name space. Make sure we use an innocuous name. */
83 #define syscall_error __syscall_error
84 #define mcount _mcount
85 #endif
87 #define PSEUDO(name, syscall_name, args) \
88 lose: SYSCALL_PIC_SETUP \
89 basr %r1,0; \
90 0: al %r1,1f-0b(%r1); \
91 br %r1; \
92 1: .long JUMPTARGET(syscall_error) - 0b; \
93 .globl syscall_error; \
94 ENTRY (name) \
95 DO_CALL (syscall_name, args); \
96 jm lose
98 #undef PSEUDO_END
99 #define PSEUDO_END(name) \
100 END (name)
102 #undef JUMPTARGET
103 #ifdef PIC
104 #define JUMPTARGET(name) name##@PLT
105 #define SYSCALL_PIC_SETUP \
106 bras %r12,1f \
107 0: .long _GLOBAL_OFFSET_TABLE_-0b \
108 1: al %r12,0(%r12)
109 #else
110 #define JUMPTARGET(name) name
111 #define SYSCALL_PIC_SETUP /* Nothing. */
112 #endif
114 /* Local label name for asm code. */
115 #ifndef L
116 #define L(name) .L##name
117 #endif
119 #endif /* __ASSEMBLER__ */