OSDN Git Service

cris: Fix build issues
[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    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18    Boston, MA 02111-1307, USA.  */
19
20 #ifndef _SYSDEP_H_
21 #define _SYSDEP_H_
22
23 #include <sys/syscall.h>
24
25 #ifndef C_LABEL
26
27 /* Define a macro we can use to construct the asm name for a C symbol.  */
28 #ifdef  __STDC__
29 #define C_LABEL(name)           name##:
30 #else
31 #define C_LABEL(name)           name/**/:
32 #endif
33
34 #endif /* C_LABEL */
35
36 #define __STR(x) #x
37 #define STR(x) __STR(x)
38
39 /* Mark the end of function named SYM.  This is used on some platforms
40    to generate correct debugging information.  */
41 #ifndef END
42 #define END(sym)
43 #endif
44
45 #undef SYS_ify
46 #define SYS_ify(syscall_name)   (__NR_##syscall_name)
47
48 #ifdef __ASSEMBLER__
49
50 #undef SYS_ify
51 #define SYS_ify(syscall_name)   __NR_##syscall_name
52
53 /* Syntactic details of assembly-code.  */
54
55 /* It is *not* generally true that "ELF uses byte-counts for .align, most
56    others use log2 of count of bytes", like some neighboring configs say.
57    See "align" in gas/read.c which is not overridden by
58    gas/config/obj-elf.c.  It takes a log2 argument.  *Some* targets
59    override it to take a byte argument.  People should read source instead
60    of relying on hearsay.  */
61 #define ALIGNARG(log2) log2
62
63 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg
64 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
65
66 /* The non-PIC jump is preferred, since it does not stall, and does not
67    invoke generation of a PLT.  These macros assume that $r0 is set up as
68    GOT register.  */
69 #ifdef __arch_v32
70 #ifdef __PIC__
71 #define PLTJUMP(_x) \
72   ba C_SYMBOL_NAME (_x):PLT                             @ \
73   nop
74
75 #define PLTCALL(_x) \
76   bsr C_SYMBOL_NAME (_x):PLT                            @ \
77   nop
78
79 #define SETUP_PIC \
80   subq 4,$sp                                            @ \
81   move.d $r0,[$sp]                                      @ \
82   lapc _GLOBAL_OFFSET_TABLE_,$r0
83
84 #define TEARDOWN_PIC move.d [$sp+],$r0
85 #else
86 #define PLTJUMP(_x) \
87   ba C_SYMBOL_NAME (_x)                                 @ \
88   nop
89
90 #define PLTCALL(_x) \
91   bsr  C_SYMBOL_NAME (_x)                               @ \
92   nop
93
94 #define SETUP_PIC
95 #define TEARDOWN_PIC
96 #endif
97
98 #else
99
100 #ifdef __PIC__
101 #define PLTJUMP(_x) \
102   add.d C_SYMBOL_NAME (_x):PLT,$pc
103
104 #define PLTCALL(_x) \
105   jsr [$r0+C_SYMBOL_NAME (_x):GOTPLT16]
106
107 #define SETUP_PIC \
108   push $r0                                              @ \
109   move.d $pc,$r0                                        @ \
110   sub.d .:GOTOFF,$r0
111
112 #define TEARDOWN_PIC pop $r0
113 #else
114 #define PLTJUMP(_x) jump C_SYMBOL_NAME (_x)
115 #define PLTCALL(_x) jsr  C_SYMBOL_NAME (_x)
116 #define SETUP_PIC
117 #define TEARDOWN_PIC
118 #endif
119
120 #endif /* __arch_v32 */
121
122 /* Define an entry point visible from C.  */
123 #define ENTRY(name) \
124   .text                                                 @ \
125   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME (name)             @ \
126   ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME (name), function)   @ \
127   .align ALIGNARG (2)                                   @ \
128   C_LABEL(name)
129
130 #undef END
131 #define END(name) \
132   ASM_SIZE_DIRECTIVE (C_SYMBOL_NAME (name))
133
134 #define PSEUDO(name, syscall_name, args) \
135   ENTRY (name)                                          @ \
136   DOARGS_##args                                         @ \
137   movu.w SYS_ify (syscall_name),$r9                     @ \
138   break 13                                              @ \
139   cmps.w -4096,$r10                                     @ \
140   bhs   0f                                              @ \
141   nop                                                   @ \
142   UNDOARGS_return_##args
143
144 #define PSEUDO_END(name) \
145 0:                                                      @ \
146   SETUP_PIC                                             @ \
147   PLTJUMP (__syscall_error)                             @ \
148   END (name)
149
150 #endif /* __ASSEMBLER__ */
151 #endif /* _SYSDEP_H_ */