or1k: add clone() from old GNU libc implementation
[uclibc-ng.git] / libc / sysdeps / linux / or1k / sysdep.h
blob4dba3f2a07661065a2fde9f33f741f8ad3147449
1 /* Copyright (C) 2011-2014 Free Software Foundation, Inc.
3 The GNU C Library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Lesser General Public License as
5 published by the Free Software Foundation; either version 2.1 of the
6 License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
13 You should have received a copy of the GNU Lesser General Public
14 License along with the GNU C Library; if not, see
15 <http://www.gnu.org/licenses/>. */
17 #ifndef _LINUX_OR1K_SYSDEP_H
18 #define _LINUX_OR1K_SYSDEP_H 1
20 #include <common/sysdep.h>
21 #include <sys/syscall.h>
23 /* In order to get __set_errno() definition in INLINE_SYSCALL. */
24 #ifndef __ASSEMBLER__
25 #include <errno.h>
26 #endif
28 #undef SYS_ify
29 #define SYS_ify(syscall_name) (__NR_##syscall_name)
31 #ifdef __ASSEMBLER__
33 /* Local label name for asm code. */
34 #define L(name) .L##name
36 #undef ret_ERRVAL
37 #define ret_ERRVAL l.jr r9; l.nop
38 #define ret_NOERRNO l.jr r9; l.nop
40 #undef DO_CALL
41 #define DO_CALL(syscall_name) \
42 l.addi r11, r0, SYS_ify (syscall_name); \
43 l.sys 1; \
44 l.nop
46 #define PSEUDO(name, syscall_name, args) \
47 ENTRY (name); \
48 DO_CALL(syscall_name); \
49 /* if -4096 < ret < 0 holds, it's an error */ \
50 l.sfgeui r11, 0xf001; \
51 l.bf L(pseudo_end); \
52 l.nop
54 #define PSEUDO_NOERRNO(name, syscall_name, args) \
55 ENTRY (name); \
56 DO_CALL(syscall_name)
58 #define PSEUDO_END(name) \
59 L(pseudo_end): \
60 l.j SYSCALL_ERROR_NAME; \
61 l.ori r3,r11,0; \
62 END (name)
64 #define PSEUDO_END_NOERRNO(name) \
65 END (name)
67 #ifndef PIC
68 /* For static code, on error jump to __syscall_error directly. */
69 # define SYSCALL_ERROR_NAME __syscall_error
70 #elif NOT_IN_libc
71 /* Use the internal name for libc/libpthread shared objects. */
72 # define SYSCALL_ERROR_NAME __GI___syscall_error
73 #else
74 /* Otherwise, on error do a full PLT jump. */
75 # define SYSCALL_ERROR_NAME plt(__syscall_error)
76 #endif
78 /* Make use of .size directive. */
79 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
81 /* Define an entry point visible from C. */
82 #define ENTRY(name) \
83 .globl C_SYMBOL_NAME(name); \
84 .type C_SYMBOL_NAME(name),@function; \
85 .align 4; \
86 C_LABEL(name) \
87 cfi_startproc; \
89 #undef END
90 #define END(name) \
91 cfi_endproc; \
92 ASM_SIZE_DIRECTIVE(name)
94 /* Since C identifiers are not normally prefixed with an underscore
95 on this system, the asm identifier `syscall_error' intrudes on the
96 C name space. Make sure we use an innocuous name. */
97 #define syscall_error __syscall_error
99 /* Specify the size in bytes of a machine register. */
100 #define REGSIZE 4
102 #endif /* __ASSEMBLER__ */
104 #endif /* linux/or1k/sysdep.h */