OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / cris / sysdep.h
1 /* Assembler macros for CRIS.
2    Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If not,
17    see <http://www.gnu.org/licenses/>.  */
18
19 #ifndef _SYSDEP_H_
20 #define _SYSDEP_H_
21
22 #include <sys/syscall.h>
23
24 #ifndef C_LABEL
25
26 /* Define a macro we can use to construct the asm name for a C symbol.  */
27 #ifdef  __STDC__
28 #define C_LABEL(name)           name##:
29 #else
30 #define C_LABEL(name)           name/**/:
31 #endif
32
33 #endif /* C_LABEL */
34
35 #define __STR(x) #x
36 #define STR(x) __STR(x)
37
38 /* Mark the end of function named SYM.  This is used on some platforms
39    to generate correct debugging information.  */
40 #ifndef END
41 #define END(sym)
42 #endif
43
44 #undef SYS_ify
45 #define SYS_ify(syscall_name)   (__NR_##syscall_name)
46
47 #ifdef __ASSEMBLER__
48
49 #undef SYS_ify
50 #define SYS_ify(syscall_name)   __NR_##syscall_name
51
52 /* Syntactic details of assembly-code.  */
53
54 /* It is *not* generally true that "ELF uses byte-counts for .align, most
55    others use log2 of count of bytes", like some neighboring configs say.
56    See "align" in gas/read.c which is not overridden by
57    gas/config/obj-elf.c.  It takes a log2 argument.  *Some* targets
58    override it to take a byte argument.  People should read source instead
59    of relying on hearsay.  */
60 #define ALIGNARG(log2) log2
61
62 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
63 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
64
65 /* The non-PIC jump is preferred, since it does not stall, and does not
66    invoke generation of a PLT.  These macros assume that $r0 is set up as
67    GOT register.  */
68 #ifdef __arch_v32
69 #ifdef __PIC__
70 #define PLTJUMP(_x) \
71   ba C_SYMBOL_NAME (_x):PLT                             @ \
72   nop
73
74 #define PLTCALL(_x) \
75   bsr C_SYMBOL_NAME (_x):PLT                            @ \
76   nop
77
78 #define SETUP_PIC \
79   subq 4,$sp                                            @ \
80   move.d $r0,[$sp]                                      @ \
81   lapc _GLOBAL_OFFSET_TABLE_,$r0
82
83 #define TEARDOWN_PIC move.d [$sp+],$r0
84 #else
85 #define PLTJUMP(_x) \
86   ba C_SYMBOL_NAME (_x)                                 @ \
87   nop
88
89 #define PLTCALL(_x) \
90   bsr  C_SYMBOL_NAME (_x)                               @ \
91   nop
92
93 #define SETUP_PIC
94 #define TEARDOWN_PIC
95 #endif
96
97 #else
98
99 #ifdef __PIC__
100 #define PLTJUMP(_x) \
101   add.d C_SYMBOL_NAME (_x):PLT,$pc
102
103 #define PLTCALL(_x) \
104   jsr [$r0+C_SYMBOL_NAME (_x):GOTPLT16]
105
106 #define SETUP_PIC \
107   push $r0                                              @ \
108   move.d $pc,$r0                                        @ \
109   sub.d .:GOTOFF,$r0
110
111 #define TEARDOWN_PIC pop $r0
112 #else
113 #define PLTJUMP(_x) jump C_SYMBOL_NAME (_x)
114 #define PLTCALL(_x) jsr  C_SYMBOL_NAME (_x)
115 #define SETUP_PIC
116 #define TEARDOWN_PIC
117 #endif
118
119 #endif /* __arch_v32 */
120
121 /* Define an entry point visible from C.  */
122 #define ENTRY(name) \
123   .text                                                 @ \
124   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name)             @ \
125   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function)   @ \
126   .align ALIGNARG (2)                                   @ \
127   C_LABEL(name)
128
129 #define HIDDEN_ENTRY(name) \
130   .text                                                 @ \
131   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name)             @ \
132   .hidden C_SYMBOL_NAME (name)                          @ \
133   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function)   @ \
134   .align ALIGNARG (2)                                   @ \
135   C_LABEL(name)
136
137 #undef END
138 #define END(name) \
139   ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
140
141 #define PSEUDO(name, syscall_name, args) \
142   ENTRY (name)                                          @ \
143   DOARGS_##args                                         @ \
144   movu.w SYS_ify (syscall_name),$r9                     @ \
145   break 13                                              @ \
146   cmps.w -4096,$r10                                     @ \
147   bhs   0f                                              @ \
148   nop                                                   @ \
149   UNDOARGS_return_##args
150
151 #define PSEUDO_END(name) \
152 0:                                                      @ \
153   SETUP_PIC                                             @ \
154   PLTJUMP (__syscall_error)                             @ \
155   END (name)
156
157 #endif /* __ASSEMBLER__ */
158 #endif /* _SYSDEP_H_ */