microblaze: sync sysdep-cancel.h/sydep.h with GNU libc
[uclibc-ng.git] / libc / sysdeps / linux / microblaze / sysdep.h
blobd4b4e90f295e86305ad48dce78f6793ab1069fea
1 /* Copyright (C) 2000-2016 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 License as
7 published by the Free Software Foundation; either version 2.1 of the
8 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 <common/sysdep.h>
21 #ifdef __ASSEMBLER__
23 # define ALIGNARG(log2) log2
24 # define ASM_SIZE_DIRECTIVE(name) .size name,.-name
26 /* Define an entry point visible from C. */
27 # define ENTRY(name) \
28 .globl C_SYMBOL_NAME(name); \
29 .type C_SYMBOL_NAME(name),@function; \
30 .align ALIGNARG(2); \
31 C_LABEL(name)
33 # undef END
34 # define END(name) ASM_SIZE_DIRECTIVE(name)
36 /* Local label name for asm code. */
37 # ifndef L
38 # define L(name) $L##name
39 # endif
41 /* We don't want the label for the error handler to be visible in the symbol
42 table when we define it here. */
43 # ifdef __PIC__
44 # define SYSCALL_ERROR_LABEL 0f
45 # else
46 # define SYSCALL_ERROR_LABEL __syscall_error
47 # endif
49 # define DO_CALL(syscall_name, args) \
50 addik r12,r0,SYS_ify (syscall_name); \
51 brki r14,8; \
52 addk r0,r0,r0;
54 # undef PSEUDO
55 # define PSEUDO(name, syscall_name, args) \
56 .text; \
57 ENTRY (name) \
58 DO_CALL (syscall_name, args); \
59 addik r12,r0,-4095; \
60 cmpu r12,r12,r3; \
61 bgei r12,SYSCALL_ERROR_LABEL;
63 # undef PSEUDO_END
64 # define PSEUDO_END(name) \
65 SYSCALL_ERROR_HANDLER; \
66 END (name)
68 # undef PSEUDO_NOERRNO
69 # define PSEUDO_NOERRNO(name, syscall_name, args) \
70 .text; \
71 ENTRY (name) \
72 DO_CALL (syscall_name, args);
74 # undef PSEUDO_END_NOERRNO
75 # define PSEUDO_END_NOERRNO(name) \
76 END (name)
78 /* The function has to return the error code. */
79 # undef PSEUDO_ERRVAL
80 # define PSEUDO_ERRVAL(name, syscall_name, args) \
81 .text; \
82 ENTRY (name) \
83 DO_CALL (syscall_name, args); \
85 # undef PSEUDO_END_ERRVAL
86 # define PSEUDO_END_ERRVAL(name) \
87 END (name)
89 # undef ret_NOERRNO
90 # define ret_NOERRNO \
91 rtsd r15,8; addk r0,r0,r0;
93 # undef ret_ERRVAL
94 # define ret_ERRVAL \
95 rtsd r15,8; rsubk r3,r3,r0;
97 #ifdef __PIC__
98 # define SYSCALL_ERROR_LABEL_DCL 0
99 # if defined _LIBC_REENTRANT
100 # define SYSCALL_ERROR_HANDLER \
101 SYSCALL_ERROR_LABEL_DCL: \
102 addik r1,r1,-16; \
103 swi r15,r1,0; \
104 swi r20,r1,8; \
105 rsubk r3,r3,r0; \
106 swi r3,r1,12; \
107 mfs r20,rpc; \
108 addik r20,r20,_GLOBAL_OFFSET_TABLE_+8; \
109 brlid r15,__errno_location@PLT; \
110 nop; \
111 lwi r4,r1,12; \
112 swi r4,r3,0; \
113 lwi r20,r1,8; \
114 lwi r15,r1,0; \
115 addik r1,r1,16; \
116 rtsd r15,8; \
117 addik r3,r0,-1;
118 # else /* !_LIBC_REENTRANT. */
119 # define SYSCALL_ERROR_HANDLER \
120 SYSCALL_ERROR_LABEL_DCL: \
121 mfs r12,rpc; \
122 addik r12,r12,_GLOBAL_OFFSET_TABLE_+8; \
123 lwi r12,r12,errno@GOT; \
124 rsubk r3,r3,r0; \
125 swi r3,r12,0; \
126 rtsd r15,8; \
127 addik r3,r0,-1;
128 # endif /* _LIBC_REENTRANT. */
129 #else
130 # define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
131 #endif /* PIC. */
133 #endif