ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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         return ret;
27
28 static inline long open(const char *pathname, int flags, int mode) 
29 {
30         KERNEL_CALL(int, sys_open, pathname, flags, mode)
31 }
32
33 static inline long dup(unsigned int fd)
34 {
35         KERNEL_CALL(int, sys_dup, fd);
36 }
37
38 static inline long close(unsigned int fd)
39 {
40         KERNEL_CALL(int, sys_close, fd);
41 }
42
43 static inline int execve(const char *filename, char *const argv[], 
44                          char *const envp[])
45 {
46         KERNEL_CALL(int, um_execve, filename, argv, envp);
47 }
48
49 static inline long waitpid(pid_t pid, unsigned int *status, int options)
50 {
51         KERNEL_CALL(pid_t, sys_wait4, pid, status, options, NULL)
52 }
53
54 static inline pid_t setsid(void)
55 {
56         KERNEL_CALL(pid_t, sys_setsid)
57 }
58
59 static inline long lseek(unsigned int fd, off_t offset, unsigned int whence)
60 {
61         KERNEL_CALL(long, sys_lseek, fd, offset, whence)
62 }
63
64 static inline int read(unsigned int fd, char * buf, int len)
65 {
66         KERNEL_CALL(int, sys_read, fd, buf, len)
67 }
68
69 static inline int write(unsigned int fd, char * buf, int len)
70 {
71         KERNEL_CALL(int, sys_write, fd, buf, len)
72 }
73
74 long sys_mmap2(unsigned long addr, unsigned long len,
75                 unsigned long prot, unsigned long flags,
76                 unsigned long fd, unsigned long pgoff);
77 int sys_execve(char *file, char **argv, char **env);
78 long sys_clone(unsigned long clone_flags, unsigned long newsp,
79                 int *parent_tid, int *child_tid);
80 long sys_fork(void);
81 long sys_vfork(void);
82 int sys_pipe(unsigned long *fildes);
83 int sys_ptrace(long request, long pid, long addr, long data);
84 struct sigaction;
85 asmlinkage long sys_rt_sigaction(int sig,
86                                 const struct sigaction __user *act,
87                                 struct sigaction __user *oact,
88                                 size_t sigsetsize);
89
90 #endif
91
92 /* Save the value of __KERNEL_SYSCALLS__, undefine it, include the underlying
93  * arch's unistd.h for the system call numbers, and restore the old 
94  * __KERNEL_SYSCALLS__.
95  */
96
97 #ifdef __KERNEL_SYSCALLS__
98 #define __SAVE_KERNEL_SYSCALLS__ __KERNEL_SYSCALLS__
99 #endif
100
101 #undef __KERNEL_SYSCALLS__
102 #include "asm/arch/unistd.h"
103
104 #ifdef __KERNEL_SYSCALLS__
105 #define __KERNEL_SYSCALLS__ __SAVE_KERNEL_SYSCALLS__
106 #endif
107
108 #endif
109
110 /*
111  * Overrides for Emacs so that we follow Linus's tabbing style.
112  * Emacs will notice this stuff at the end of the file and automatically
113  * adjust the settings for this buffer only.  This must remain at the end
114  * of the file.
115  * ---------------------------------------------------------------------------
116  * Local variables:
117  * c-file-style: "linux"
118  * End:
119  */