This source file includes following definitions.
- fork
- idle
- setup
- open
- dup
- close
- _exit
- write
- read
- wait
1 #ifndef _ALPHA_UNISTD_H
2 #define _ALPHA_UNISTD_H
3
4
5
6
7
8
9
10
11
12 #define _syscall0(type,name) \
13 type name(void) \
14 { \
15 return (type) -1; \
16 }
17
18 #define _syscall1(type,name,type1,arg1) \
19 type name(type1 arg1) \
20 { \
21 return (type) -1; \
22 }
23
24 #define _syscall2(type,name,type1,arg1,type2,arg2) \
25 type name(type1 arg1,type2 arg2) \
26 { \
27 return (type) -1; \
28 }
29
30 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
31 type name(type1 arg1,type2 arg2,type3 arg3) \
32 { \
33 return (type) -1; \
34 }
35
36 #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
37 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
38 { \
39 return (type) -1; \
40 }
41
42 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
43 type5,arg5) \
44 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
45 { \
46 return (type) -1; \
47 }
48
49 #ifdef __KERNEL_SYSCALLS__
50
51 extern unsigned long kernel_fork(void);
52 static inline unsigned long fork(void)
53 {
54 printk("[%d]fork()\n",current->pid);
55 return kernel_fork();
56 }
57
58 extern void sys_idle(void);
59 static inline void idle(void)
60 {
61 printk("[%d]idle()\n",current->pid);
62 sys_idle();
63 for(;;);
64 }
65
66 extern int sys_setup(void);
67 static inline int setup(void)
68 {
69 int retval;
70
71 printk("[%d]setup()\n",current->pid);
72 retval = sys_setup();
73 printk("[%d]setup() returned %d\n",current->pid, retval);
74 }
75
76 extern int sys_open(const char *, int, int);
77 static inline int open(const char * name, int mode, int flags)
78 {
79 int fd;
80 printk("[%d]open(%s,%d,%d)\n",current->pid, name, mode, flags);
81 fd = sys_open(name, mode, flags);
82 printk("[%d]open(%s,%d,%d)=%d\n",current->pid, name, mode, flags, fd);
83 return fd;
84 }
85
86 extern int sys_dup(int);
87 static inline int dup(int fd)
88 {
89 int newfd = sys_dup(fd);
90 printk("[%d]dup(%d)=%d\n",current->pid, fd, newfd);
91 return newfd;
92 }
93
94 static inline int close(int fd)
95 {
96 printk("[%d]close(%d)\n",current->pid,fd);
97 return sys_close(fd);
98 }
99
100 extern int sys_exit(int);
101 static inline int _exit(int value)
102 {
103 printk("[%d]_exit(%d)\n", current->pid, value);
104 return sys_exit(value);
105 }
106
107 #define exit(x) _exit(x)
108
109 extern int sys_write(int, const char *, int);
110 static inline int write(int fd, const char * buf, int nr)
111 {
112 return sys_write(fd, buf, nr);
113 }
114
115 extern int sys_read(int, char *, int);
116 static inline int read(int fd, char * buf, int nr)
117 {
118 int res = sys_read(fd, buf, nr);
119 printk("[%d]read(%d,%s,%d)=%d\n",current->pid, fd, buf, nr, res);
120 return res;
121 }
122
123 #define execve(x,y,z) ({ printk("[%d]execve(%s,%p,%p)\n",current->pid, x, y, z); -1; })
124 #define waitpid(x,y,z) sys_waitpid(x,y,z)
125 #define setsid() ({ printk("[%d]setsid()\n",current->pid); -1; })
126 #define sync() ({ printk("[%d]sync()\n",current->pid); -1; })
127
128 extern int sys_waitpid(int, int *, int);
129 static inline pid_t wait(int * wait_stat)
130 {
131 long retval, i;
132 printk("[%d]wait(%p)\n", current->pid, wait_stat);
133 retval = waitpid(-1,wait_stat,0);
134 printk("[%d]wait(%p) returned %ld\n", current->pid, wait_stat, retval);
135 for (i = 0; i < 1000000000; i++);
136 return retval;
137 }
138
139 #endif
140
141 #endif