uml-patch-2.6.6-1
[linux-2.6.git] / include / asm-um / unistd.h
1 /* 
2  * Copyright (C) 2000, 2001  Jeff Dike (jdike@karaya.com)
3  * Licensed under the GPL
4  */
5
6 #ifndef _UM_UNISTD_H_
7 #define _UM_UNISTD_H_
8
9 #include <linux/syscalls.h>
10 #include "linux/resource.h"
11 #include "asm/uaccess.h"
12
13 extern int um_execve(const char *file, char *const argv[], char *const env[]);
14
15 #ifdef __KERNEL_SYSCALLS__
16
17 #include <linux/compiler.h>
18 #include <linux/types.h>
19
20 #define KERNEL_CALL(ret_t, sys, args...)        \
21         mm_segment_t fs = get_fs();             \
22         ret_t ret;                              \
23         set_fs(KERNEL_DS);                      \
24         ret = sys(args);                        \
25         set_fs(fs);                             \
26         if (ret >= 0)                           \
27                 return ret;                     \
28         errno = -(long)ret;                     \
29         return -1;
30
31 static inline long open(const char *pathname, int flags, int mode) 
32 {
33         KERNEL_CALL(int, sys_open, pathname, flags, mode)
34 }
35
36 static inline long dup(unsigned int fd)
37 {
38         KERNEL_CALL(int, sys_dup, fd);
39 }
40
41 static inline long close(unsigned int fd)
42 {
43         KERNEL_CALL(int, sys_close, fd);
44 }
45
46 static inline int execve(const char *filename, char *const argv[], 
47                          char *const envp[])
48 {
49         KERNEL_CALL(int, um_execve, filename, argv, envp);
50 }
51
52 static inline long waitpid(pid_t pid, unsigned int *status, int options)
53 {
54         KERNEL_CALL(pid_t, sys_wait4, pid, status, options, NULL)
55 }
56
57 static inline pid_t setsid(void)
58 {
59         KERNEL_CALL(pid_t, sys_setsid)
60 }
61
62 static inline long lseek(unsigned int fd, off_t offset, unsigned int whence)
63 {
64         KERNEL_CALL(long, sys_lseek, fd, offset, whence)
65 }
66
67 static inline int read(unsigned int fd, char * buf, int len)
68 {
69         KERNEL_CALL(int, sys_read, fd, buf, len)
70 }
71
72 static inline int write(unsigned int fd, char * buf, int len)
73 {
74         KERNEL_CALL(int, sys_write, fd, buf, len)
75 }
76
77 long sys_mmap2(unsigned long addr, unsigned long len,
78                 unsigned long prot, unsigned long flags,
79                 unsigned long fd, unsigned long pgoff);
80 int sys_execve(char *file, char **argv, char **env);
81 long sys_clone(unsigned long clone_flags, unsigned long newsp,
82                 int *parent_tid, int *child_tid);
83 long sys_fork(void);
84 long sys_vfork(void);
85 int sys_pipe(unsigned long *fildes);
86 int sys_ptrace(long request, long pid, long addr, long data);
87 struct sigaction;
88 asmlinkage long sys_rt_sigaction(int sig,
89                                 const struct sigaction __user *act,
90                                 struct sigaction __user *oact,
91                                 size_t sigsetsize);
92
93 #endif
94
95 /* Save the value of __KERNEL_SYSCALLS__, undefine it, include the underlying
96  * arch's unistd.h for the system call numbers, and restore the old 
97  * __KERNEL_SYSCALLS__.
98  */
99
100 #ifdef __KERNEL_SYSCALLS__
101 #define __SAVE_KERNEL_SYSCALLS__ __KERNEL_SYSCALLS__
102 #endif
103
104 #undef __KERNEL_SYSCALLS__
105 #include "asm/arch/unistd.h"
106
107 #ifdef __KERNEL_SYSCALLS__
108 #define __KERNEL_SYSCALLS__ __SAVE_KERNEL_SYSCALLS__
109 #endif
110
111 #endif
112
113 /*
114  * Overrides for Emacs so that we follow Linus's tabbing style.
115  * Emacs will notice this stuff at the end of the file and automatically
116  * adjust the settings for this buffer only.  This must remain at the end
117  * of the file.
118  * ---------------------------------------------------------------------------
119  * Local variables:
120  * c-file-style: "linux"
121  * End:
122  */