1 /* Assembler macros for Xtensa processors.
2 Copyright (C) 2001, 2007 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <sys/syscall.h>
23 #define ALIGNARG(log2) 1 << log2
24 #define ASM_TYPE_DIRECTIVE(name, typearg) .type name, typearg
25 #define ASM_SIZE_DIRECTIVE(name) .size name, . - name
28 #define C_LABEL(name) name :
30 #define C_LABEL(name) name/**/:
34 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
35 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name), @function); \
39 entry sp, FRAMESIZE; \
42 #define HIDDEN_ENTRY(name) \
43 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
44 .hidden C_SYMBOL_NAME(name); \
45 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name), @function); \
49 entry sp, FRAMESIZE; \
53 #define END(name) ASM_SIZE_DIRECTIVE(name)
55 /* Define a macro for this directive so it can be removed in a few places. */
56 #define LITERAL_POSITION .literal_position
60 /* The "@PLT" suffix is currently a no-op for non-shared linking, but
61 it doesn't hurt to use it conditionally for PIC code in case that
63 #define JUMPTARGET(name) name##@PLT
65 #define JUMPTARGET(name) name
69 #define CALL_MCOUNT /* Do nothing. */
72 /* Linux uses a negative return value to indicate syscall errors,
73 unlike most Unices, which use the condition codes' carry flag.
75 Since version 2.1 the return value of a system call might be
76 negative even if the call succeeded. E.g., the `lseek' system call
77 might return a large offset. Therefore we must not anymore test
78 for < 0, but test for a real error by making sure the value in a2
79 is a real error number. Linus said he will make sure the no syscall
80 returns a value in -1 .. -4095 as a valid result so we can safely
83 /* We don't want the label for the error handler to be global when we define
85 #define SYSCALL_ERROR_LABEL 0f
88 #define PSEUDO(name, syscall_name, args) \
91 DO_CALL (syscall_name, args); \
93 bgeu a2, a4, SYSCALL_ERROR_LABEL; \
97 #define PSEUDO_END(name) \
98 SYSCALL_ERROR_HANDLER \
101 #undef PSEUDO_NOERRNO
102 #define PSEUDO_NOERRNO(name, syscall_name, args) \
105 DO_CALL (syscall_name, args)
107 #undef PSEUDO_END_NOERRNO
108 #define PSEUDO_END_NOERRNO(name) \
112 #define ret_NOERRNO retw
114 /* The function has to return the error code. */
116 #define PSEUDO_ERRVAL(name, syscall_name, args) \
119 DO_CALL (syscall_name, args); \
122 #undef PSEUDO_END_ERRVAL
123 #define PSEUDO_END_ERRVAL(name) \
126 #define ret_ERRVAL retw
128 #if defined RTLD_PRIVATE_ERRNO
129 # define SYSCALL_ERROR_HANDLER \
130 0: movi a4, rtld_errno; \
136 #elif defined _LIBC_REENTRANT
138 # if defined USE___THREAD
140 # define SYSCALL_ERROR_ERRNO __libc_errno
142 # define SYSCALL_ERROR_ERRNO errno
144 # define SYSCALL_ERROR_HANDLER \
145 0: rur a4, THREADPTR; \
146 movi a3, SYSCALL_ERROR_ERRNO@TPOFF; \
152 # else /* !USE___THREAD */
153 # define SYSCALL_ERROR_HANDLER \
156 movi a4, __errno_location@PLT; \
161 # endif /* !USE___THREAD */
162 #else /* !_LIBC_REENTRANT */
163 #define SYSCALL_ERROR_HANDLER \
169 #endif /* _LIBC_REENTRANT */
171 #endif /* __ASSEMBLER__ */