OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [sysdeps/] [linux/] [arm/] [bits/] [syscalls.h] - Blame information for rev 1779

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
#ifndef _BITS_SYSCALLS_H
2
#define _BITS_SYSCALLS_H
3
#ifndef _SYSCALL_H
4
# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
5
#endif
6
 
7
/* This includes the `__NR_<name>' syscall numbers taken from the Linux kernel
8
 * header files.  It also defines the traditional `SYS_<name>' macros for older
9
 * programs.  */
10
#include <bits/sysnum.h>
11
 
12
#ifndef __set_errno
13
# define __set_errno(val) (*__errno_location ()) = (val)
14
#endif
15
#ifndef SYS_ify
16
# define SYS_ify(syscall_name)  (__NR_##syscall_name)
17
#endif
18
 
19
/*
20
   Some of the sneaky macros in the code were taken from
21
   glibc-2.3.2/sysdeps/unix/sysv/linux/arm/sysdep.h
22
*/
23
 
24
#ifndef __ASSEMBLER__
25
 
26
#undef _syscall0
27
#define _syscall0(type,name) \
28
type name(void) \
29
{ \
30
return (type) (INLINE_SYSCALL(name, 0)); \
31
}
32
 
33
#undef _syscall1
34
#define _syscall1(type,name,type1,arg1) \
35
type name(type1 arg1) \
36
{ \
37
return (type) (INLINE_SYSCALL(name, 1, arg1)); \
38
}
39
 
40
#undef _syscall2
41
#define _syscall2(type,name,type1,arg1,type2,arg2) \
42
type name(type1 arg1,type2 arg2) \
43
{ \
44
return (type) (INLINE_SYSCALL(name, 2, arg1, arg2)); \
45
}
46
 
47
#undef _syscall3
48
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
49
type name(type1 arg1,type2 arg2,type3 arg3) \
50
{ \
51
return (type) (INLINE_SYSCALL(name, 3, arg1, arg2, arg3)); \
52
}
53
 
54
#undef _syscall4
55
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
56
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
57
{ \
58
return (type) (INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4)); \
59
}
60
 
61
#undef _syscall5
62
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
63
          type5,arg5) \
64
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
65
{ \
66
return (type) (INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5)); \
67
}
68
 
69
#undef _syscall6
70
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
71
          type5,arg5,type6,arg6) \
72
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \
73
{ \
74
return (type) (INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6)); \
75
}
76
 
77
#undef _syscall7
78
#define _syscall7(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
79
          type5,arg5,type6,arg6,type7,arg7) \
80
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6,type7 arg7) \
81
{ \
82
return (type) (INLINE_SYSCALL(name, 7, arg1, arg2, arg3, arg4, arg5, arg6, arg7)); \
83
}
84
 
85
 
86
#undef INLINE_SYSCALL
87
#define INLINE_SYSCALL(name, nr, args...)                               \
88
  ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args);    \
89
     if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0)) \
90
       {                                                                \
91
         __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, ));          \
92
         _sys_result = (unsigned int) -1;                               \
93
       }                                                                \
94
     (int) _sys_result; })
95
 
96
#undef INTERNAL_SYSCALL_DECL
97
#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
98
 
99
#undef INTERNAL_SYSCALL
100
#define INTERNAL_SYSCALL(name, err, nr, args...)                \
101
  ({ unsigned int _sys_result;                                  \
102
     {                                                          \
103
       register int _a1 asm ("a1");                             \
104
       LOAD_ARGS_##nr (args)                                    \
105
       asm volatile ("swi       %1      @ syscall " #name       \
106
                     : "=r" (_a1)                               \
107
                     : "i" (SYS_ify(name)) ASM_ARGS_##nr        \
108
                     : "memory");                               \
109
       _sys_result = _a1;                                       \
110
     }                                                          \
111
     (int) _sys_result; })
112
 
113
#undef INTERNAL_SYSCALL_ERROR_P
114
#define INTERNAL_SYSCALL_ERROR_P(val, err) \
115
  ((unsigned int) (val) >= 0xfffff001u)
116
 
117
#undef INTERNAL_SYSCALL_ERRNO
118
#define INTERNAL_SYSCALL_ERRNO(val, err)        (-(val))
119
 
120
#define LOAD_ARGS_0()
121
#define ASM_ARGS_0
122
#define LOAD_ARGS_1(a1)                         \
123
  _a1 = (int) (a1);                             \
124
  LOAD_ARGS_0 ()
125
#define ASM_ARGS_1      ASM_ARGS_0, "r" (_a1)
126
#define LOAD_ARGS_2(a1, a2)                     \
127
  register int _a2 asm ("a2") = (int) (a2);     \
128
  LOAD_ARGS_1 (a1)
129
#define ASM_ARGS_2      ASM_ARGS_1, "r" (_a2)
130
#define LOAD_ARGS_3(a1, a2, a3)                 \
131
  register int _a3 asm ("a3") = (int) (a3);     \
132
  LOAD_ARGS_2 (a1, a2)
133
#define ASM_ARGS_3      ASM_ARGS_2, "r" (_a3)
134
#define LOAD_ARGS_4(a1, a2, a3, a4)             \
135
  register int _a4 asm ("a4") = (int) (a4);     \
136
  LOAD_ARGS_3 (a1, a2, a3)
137
#define ASM_ARGS_4      ASM_ARGS_3, "r" (_a4)
138
#define LOAD_ARGS_5(a1, a2, a3, a4, a5)         \
139
  register int _v1 asm ("v1") = (int) (a5);     \
140
  LOAD_ARGS_4 (a1, a2, a3, a4)
141
#define ASM_ARGS_5      ASM_ARGS_4, "r" (_v1)
142
#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6)     \
143
  register int _v2 asm ("v2") = (int) (a6);     \
144
  LOAD_ARGS_5 (a1, a2, a3, a4, a5)
145
#define ASM_ARGS_6      ASM_ARGS_5, "r" (_v2)
146
#define LOAD_ARGS_7(a1, a2, a3, a4, a5, a6, a7) \
147
  register int _v3 asm ("v3") = (int) (a7);     \
148
  LOAD_ARGS_6 (a1, a2, a3, a4, a5, a6)
149
#define ASM_ARGS_7      ASM_ARGS_6, "r" (_v3)
150
 
151
 
152
#endif /* __ASSEMBLER__ */
153
#endif /* _BITS_SYSCALLS_H */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.