kernel.org linux-2.6.10
[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__
16 /* We get __ARCH_WANT_OLD_STAT and __ARCH_WANT_STAT64 from the base arch */
17 #define __ARCH_WANT_IPC_PARSE_VERSION
18 #define __ARCH_WANT_OLD_READDIR
19 #define __ARCH_WANT_SYS_ALARM
20 #define __ARCH_WANT_SYS_GETHOSTNAME
21 #define __ARCH_WANT_SYS_PAUSE
22 #define __ARCH_WANT_SYS_SGETMASK
23 #define __ARCH_WANT_SYS_SIGNAL
24 #define __ARCH_WANT_SYS_TIME
25 #define __ARCH_WANT_SYS_UTIME
26 #define __ARCH_WANT_SYS_WAITPID
27 #define __ARCH_WANT_SYS_SOCKETCALL
28 #define __ARCH_WANT_SYS_FADVISE64
29 #define __ARCH_WANT_SYS_GETPGRP
30 #define __ARCH_WANT_SYS_LLSEEK
31 #define __ARCH_WANT_SYS_NICE
32 #define __ARCH_WANT_SYS_OLD_GETRLIMIT
33 #define __ARCH_WANT_SYS_OLDUMOUNT
34 #define __ARCH_WANT_SYS_SIGPENDING
35 #define __ARCH_WANT_SYS_SIGPROCMASK
36 #define __ARCH_WANT_SYS_RT_SIGACTION
37 #endif
38
39 #ifdef __KERNEL_SYSCALLS__
40
41 #include <linux/compiler.h>
42 #include <linux/types.h>
43
44 #define KERNEL_CALL(ret_t, sys, args...)        \
45         mm_segment_t fs = get_fs();             \
46         ret_t ret;                              \
47         set_fs(KERNEL_DS);                      \
48         ret = sys(args);                        \
49         set_fs(fs);                             \
50         if (ret >= 0)                           \
51                 return ret;                     \
52         errno = -(long)ret;                     \
53         return -1;
54
55 static inline long open(const char *pathname, int flags, int mode) 
56 {
57         KERNEL_CALL(int, sys_open, pathname, flags, mode)
58 }
59
60 static inline long dup(unsigned int fd)
61 {
62         KERNEL_CALL(int, sys_dup, fd);
63 }
64
65 static inline long close(unsigned int fd)
66 {
67         KERNEL_CALL(int, sys_close, fd);
68 }
69
70 static inline int execve(const char *filename, char *const argv[], 
71                          char *const envp[])
72 {
73         KERNEL_CALL(int, um_execve, filename, argv, envp);
74 }
75
76 static inline long waitpid(pid_t pid, unsigned int *status, int options)
77 {
78         KERNEL_CALL(pid_t, sys_wait4, pid, status, options, NULL)
79 }
80
81 static inline pid_t setsid(void)
82 {
83         KERNEL_CALL(pid_t, sys_setsid)
84 }
85
86 static inline off_t lseek(unsigned int fd, off_t offset, unsigned int whence)
87 {
88         KERNEL_CALL(long, sys_lseek, fd, offset, whence)
89 }
90
91 static inline int read(unsigned int fd, char * buf, int len)
92 {
93         KERNEL_CALL(int, sys_read, fd, buf, len)
94 }
95
96 static inline int write(unsigned int fd, char * buf, int len)
97 {
98         KERNEL_CALL(int, sys_write, fd, buf, len)
99 }
100
101 long sys_mmap2(unsigned long addr, unsigned long len,
102                 unsigned long prot, unsigned long flags,
103                 unsigned long fd, unsigned long pgoff);
104 long sys_execve(char *file, char **argv, char **env);
105 long sys_clone(unsigned long clone_flags, unsigned long newsp,
106                 int *parent_tid, int *child_tid);
107 long sys_fork(void);
108 long sys_vfork(void);
109 long sys_pipe(unsigned long *fildes);
110 struct sigaction;
111 asmlinkage long sys_rt_sigaction(int sig,
112                                 const struct sigaction __user *act,
113                                 struct sigaction __user *oact,
114                                 size_t sigsetsize);
115
116 #endif
117
118 /* Save the value of __KERNEL_SYSCALLS__, undefine it, include the underlying
119  * arch's unistd.h for the system call numbers, and restore the old 
120  * __KERNEL_SYSCALLS__.
121  */
122
123 #ifdef __KERNEL_SYSCALLS__
124 #define __SAVE_KERNEL_SYSCALLS__ __KERNEL_SYSCALLS__
125 #endif
126
127 #undef __KERNEL_SYSCALLS__
128 #include "asm/arch/unistd.h"
129
130 #ifdef __KERNEL_SYSCALLS__
131 #define __KERNEL_SYSCALLS__ __SAVE_KERNEL_SYSCALLS__
132 #endif
133
134 #endif
135
136 /*
137  * Overrides for Emacs so that we follow Linus's tabbing style.
138  * Emacs will notice this stuff at the end of the file and automatically
139  * adjust the settings for this buffer only.  This must remain at the end
140  * of the file.
141  * ---------------------------------------------------------------------------
142  * Local variables:
143  * c-file-style: "linux"
144  * End:
145  */