OSDN Git Service

2005-11-03 Shaun Jackman <sjackman@gmail.com>
[pf3gnuchains/pf3gnuchains4x.git] / newlib / libc / include / sys / unistd.h
1 #ifndef _SYS_UNISTD_H
2 #define _SYS_UNISTD_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #include <_ansi.h>
9 #include <sys/types.h>
10 #include <sys/_types.h>
11 #define __need_size_t
12 #define __need_ptrdiff_t
13 #include <stddef.h>
14
15 extern char **environ;
16
17 void    _EXFUN(_exit, (int __status ) _ATTRIBUTE ((noreturn)));
18
19 int     _EXFUN(access,(const char *__path, int __amode ));
20 unsigned  _EXFUN(alarm, (unsigned __secs ));
21 int     _EXFUN(chdir, (const char *__path ));
22 int     _EXFUN(chmod, (const char *__path, mode_t __mode ));
23 #if !defined(__INSIDE_CYGWIN__)
24 int     _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
25 #endif
26 #if defined(__CYGWIN__) || defined(__rtems__)
27 int     _EXFUN(chroot, (const char *__path ));
28 #endif
29 int     _EXFUN(close, (int __fildes ));
30 char    _EXFUN(*ctermid, (char *__s ));
31 char    _EXFUN(*cuserid, (char *__s ));
32 #if defined(__CYGWIN__)
33 int     _EXFUN(daemon, (int nochdir, int noclose));
34 #endif
35 int     _EXFUN(dup, (int __fildes ));
36 int     _EXFUN(dup2, (int __fildes, int __fildes2 ));
37 #if defined(__CYGWIN__)
38 void    _EXFUN(endusershell, (void));
39 #endif
40 int     _EXFUN(execl, (const char *__path, const char *, ... ));
41 int     _EXFUN(execle, (const char *__path, const char *, ... ));
42 int     _EXFUN(execlp, (const char *__file, const char *, ... ));
43 int     _EXFUN(execv, (const char *__path, char * const __argv[] ));
44 int     _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] ));
45 int     _EXFUN(execvp, (const char *__file, char * const __argv[] ));
46 #if defined(__CYGWIN__) || defined(__rtems__)
47 int     _EXFUN(fchdir, (int __fildes));
48 #endif
49 int     _EXFUN(fchmod, (int __fildes, mode_t __mode ));
50 #if !defined(__INSIDE_CYGWIN__)
51 int     _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
52 #endif
53 pid_t   _EXFUN(fork, (void ));
54 long    _EXFUN(fpathconf, (int __fd, int __name ));
55 int     _EXFUN(fsync, (int __fd));
56 int     _EXFUN(fdatasync, (int __fd));
57 char    _EXFUN(*getcwd, (char *__buf, size_t __size ));
58 #if defined(__CYGWIN__)
59 int     _EXFUN(getdomainname ,(char *__name, size_t __len));
60 #endif
61 #if !defined(__INSIDE_CYGWIN__)
62 gid_t   _EXFUN(getegid, (void ));
63 uid_t   _EXFUN(geteuid, (void ));
64 gid_t   _EXFUN(getgid, (void ));
65 #endif
66 int     _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] ));
67 #if defined(__CYGWIN__)
68 long    _EXFUN(gethostid, (void));
69 #endif
70 char    _EXFUN(*getlogin, (void ));
71 #if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
72 int _EXFUN(getlogin_r, (char *name, size_t namesize) );
73 #endif
74 char    _EXFUN(*getpass, (const char *__prompt));
75 size_t  _EXFUN(getpagesize, (void));
76 #if defined(__CYGWIN__)
77 int    _EXFUN(getpeereid, (int, uid_t *, gid_t *));
78 #endif
79 pid_t   _EXFUN(getpgid, (pid_t));
80 pid_t   _EXFUN(getpgrp, (void ));
81 pid_t   _EXFUN(getpid, (void ));
82 pid_t   _EXFUN(getppid, (void ));
83 #ifdef __CYGWIN__
84 pid_t   _EXFUN(getsid, (pid_t));
85 #endif
86 #if !defined(__INSIDE_CYGWIN__)
87 uid_t   _EXFUN(getuid, (void ));
88 #endif
89 #ifdef __CYGWIN__
90 char *  _EXFUN(getusershell, (void));
91 char    _EXFUN(*getwd, (char *__buf ));
92 int     _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser));
93 #endif
94 int     _EXFUN(isatty, (int __fildes ));
95 #if !defined(__INSIDE_CYGWIN__)
96 int     _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
97 #endif
98 int     _EXFUN(link, (const char *__path1, const char *__path2 ));
99 int     _EXFUN(nice, (int __nice_value ));
100 #if !defined(__INSIDE_CYGWIN__)
101 off_t   _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
102 #endif
103 long    _EXFUN(pathconf, (const char *__path, int __name ));
104 int     _EXFUN(pause, (void ));
105 #ifdef __CYGWIN__
106 int     _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
107 #endif
108 int     _EXFUN(pipe, (int __fildes[2] ));
109 ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
110 ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
111 _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
112 #if defined(__CYGWIN__)
113 int     _EXFUN(rresvport, (int *__alport));
114 int     _EXFUN(revoke, (char *__path));
115 #endif
116 int     _EXFUN(rmdir, (const char *__path ));
117 #if defined(__CYGWIN__)
118 int     _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
119 #endif
120 void *  _EXFUN(sbrk,  (ptrdiff_t __incr));
121 #if !defined(__INSIDE_CYGWIN__)
122 #if defined(__CYGWIN__)
123 int     _EXFUN(setegid, (gid_t __gid ));
124 int     _EXFUN(seteuid, (uid_t __uid ));
125 #endif
126 int     _EXFUN(setgid, (gid_t __gid ));
127 #endif
128 #if defined(__CYGWIN__)
129 int     _EXFUN(setgroups, (int ngroups, const gid_t *grouplist ));
130 #endif
131 int     _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
132 int     _EXFUN(setpgrp, (void ));
133 #if defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
134 int     _EXFUN(setregid, (gid_t __rgid, gid_t __egid));
135 int     _EXFUN(setreuid, (uid_t __ruid, uid_t __euid));
136 #endif
137 pid_t   _EXFUN(setsid, (void ));
138 #if !defined(__INSIDE_CYGWIN__)
139 int     _EXFUN(setuid, (uid_t __uid ));
140 #endif
141 #if defined(__CYGWIN__)
142 void    _EXFUN(setusershell, (void));
143 #endif
144 unsigned _EXFUN(sleep, (unsigned int __seconds ));
145 void    _EXFUN(swab, (const void *, void *, ssize_t));
146 long    _EXFUN(sysconf, (int __name ));
147 pid_t   _EXFUN(tcgetpgrp, (int __fildes ));
148 int     _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
149 char    _EXFUN(*ttyname, (int __fildes ));
150 #if defined(__CYGWIN__)
151 int     _EXFUN(ttyname_r, (int, char *, size_t)); 
152 #endif
153 int     _EXFUN(unlink, (const char *__path ));
154 int     _EXFUN(vhangup, (void ));
155 _READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
156
157 #ifdef __CYGWIN__
158 # define __UNISTD_GETOPT__
159 # include <getopt.h>
160 # undef __UNISTD_GETOPT__
161 #else
162 extern char *optarg;                    /* getopt(3) external variables */
163 extern int optind, opterr, optopt;
164 int      getopt(int, char * const [], const char *);
165 extern int optreset;                    /* getopt(3) external variable */
166 #endif
167
168 #ifndef        _POSIX_SOURCE
169 pid_t   _EXFUN(vfork, (void ));
170
171 extern char *suboptarg;                 /* getsubopt(3) external variable */
172 int      getsubopt(char **, char * const *, char **);
173 #endif /* _POSIX_SOURCE */
174
175 #ifdef _COMPILING_NEWLIB
176 /* Provide prototypes for most of the _<systemcall> names that are
177    provided in newlib for some compilers.  */
178 int     _EXFUN(_close, (int __fildes ));
179 pid_t   _EXFUN(_fork, (void ));
180 pid_t   _EXFUN(_getpid, (void ));
181 int     _EXFUN(_link, (const char *__path1, const char *__path2 ));
182 _off_t   _EXFUN(_lseek, (int __fildes, _off_t __offset, int __whence ));
183 #ifdef __LARGE64_FILES
184 _off64_t _EXFUN(_lseek64, (int __filedes, _off64_t __offset, int __whence ));
185 #endif
186 _READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte ));
187 void *  _EXFUN(_sbrk,  (ptrdiff_t __incr));
188 int     _EXFUN(_unlink, (const char *__path ));
189 _READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nbyte ));
190 int     _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
191 #endif
192
193 #if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__)
194 #if !defined(__INSIDE_CYGWIN__)
195 int     _EXFUN(ftruncate, (int __fd, off_t __length));
196 int     _EXFUN(truncate, (const char *, off_t __length));
197 #endif
198 #endif
199 #if defined(__CYGWIN__) || defined(__rtems__)
200 int     _EXFUN(getdtablesize, (void));
201 int     _EXFUN(setdtablesize, (int));
202 useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
203 unsigned _EXFUN(usleep, (unsigned int __useconds));
204 #if !(defined  (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
205 /* winsock[2].h defines as __stdcall, and with int as 2nd arg */
206  int    _EXFUN(gethostname, (char *__name, size_t __len));
207 #endif
208 char *  _EXFUN(mktemp, (char *));
209 #if defined(__CYGWIN__)
210 void    _EXFUN(sync, (void));
211 #else /* defined(__rtems__) */
212 int     _EXFUN(sync, (void));
213 #endif
214 #endif
215 int     _EXFUN(readlink, (const char *__path, char *__buf, int __buflen));
216 int     _EXFUN(symlink, (const char *__name1, const char *__name2));
217
218 #define F_OK    0
219 #define R_OK    4
220 #define W_OK    2
221 #define X_OK    1
222
223 # define        SEEK_SET        0
224 # define        SEEK_CUR        1
225 # define        SEEK_END        2
226
227 #include <sys/features.h>
228
229 #define STDIN_FILENO    0       /* standard input file descriptor */
230 #define STDOUT_FILENO   1       /* standard output file descriptor */
231 #define STDERR_FILENO   2       /* standard error file descriptor */
232
233 /*
234  *  4.8.1 Get Configurable System Variables, P1003.1b-1993, p. 96
235  *
236  *  NOTE: Table 4-2, Configurable System Variables, p. 96
237  */
238
239 #define _SC_ARG_MAX                 0
240 #define _SC_CHILD_MAX               1
241 #define _SC_CLK_TCK                 2
242 #define _SC_NGROUPS_MAX             3
243 #define _SC_OPEN_MAX                4
244   /* no _SC_STREAM_MAX */
245 #define _SC_JOB_CONTROL             5
246 #define _SC_SAVED_IDS               6
247 #define _SC_VERSION                 7
248 #define _SC_PAGESIZE                8
249 /* CYGWIN-specific values .. do not touch */
250 #define _SC_NPROCESSORS_CONF        9
251 #define _SC_NPROCESSORS_ONLN       10
252 #define _SC_PHYS_PAGES             11
253 #define _SC_AVPHYS_PAGES           12
254 /* end of CYGWIN-specific values */
255 #define _SC_MQ_OPEN_MAX            13
256 #define _SC_MQ_PRIO_MAX            14
257 #define _SC_RTSIG_MAX              15
258 #define _SC_SEM_NSEMS_MAX          16
259 #define _SC_SEM_VALUE_MAX          17
260 #define _SC_SIGQUEUE_MAX           18
261 #define _SC_TIMER_MAX              19
262 #define _SC_TZNAME_MAX             20
263
264 #define _SC_ASYNCHRONOUS_IO        21
265 #define _SC_FSYNC                  22
266 #define _SC_MAPPED_FILES           23
267 #define _SC_MEMLOCK                24
268 #define _SC_MEMLOCK_RANGE          25
269 #define _SC_MEMORY_PROTECTION      26
270 #define _SC_MESSAGE_PASSING        27
271 #define _SC_PRIORITIZED_IO         28
272 #define _SC_REALTIME_SIGNALS       29
273 #define _SC_SEMAPHORES             30
274 #define _SC_SHARED_MEMORY_OBJECTS  31
275 #define _SC_SYNCHRONIZED_IO        32
276 #define _SC_TIMERS                 33
277 #define _SC_AIO_LISTIO_MAX         34
278 #define _SC_AIO_MAX                35
279 #define _SC_AIO_PRIO_DELTA_MAX     36
280 #define _SC_DELAYTIMER_MAX         37
281
282 /*
283  *  P1003.1c/D10, p. 52 adds the following.
284  */
285
286 #define _SC_THREAD_KEYS_MAX              38
287 #define _SC_THREAD_STACK_MIN             39
288 #define _SC_THREAD_THREADS_MAX           40
289 #define _SC_TTY_NAME_MAX                 41
290
291 #define _SC_THREADS                      42
292 #define _SC_THREAD_ATTR_STACKADDR        43
293 #define _SC_THREAD_ATTR_STACKSIZE        44
294 #define _SC_THREAD_PRIORITY_SCHEDULING   45
295 #define _SC_THREAD_PRIO_INHERIT          46
296 /* _SC_THREAD_PRIO_PROTECT was _SC_THREAD_PRIO_CEILING in early drafts */
297 #define _SC_THREAD_PRIO_PROTECT          47
298 #define _SC_THREAD_PRIO_CEILING          _SC_THREAD_PRIO_PROTECT
299 #define _SC_THREAD_PROCESS_SHARED        48
300 #define _SC_THREAD_SAFE_FUNCTIONS        49
301 #define _SC_GETGR_R_SIZE_MAX             50
302 #define _SC_GETPW_R_SIZE_MAX             51
303 #define _SC_LOGIN_NAME_MAX               52
304 #define _SC_THREAD_DESTRUCTOR_ITERATIONS 53
305
306 #if !defined(__CYGWIN__) && !defined(__rtems__)
307 #define _SC_STREAM_MAX                  100
308 #define _SC_PRIORITY_SCHEDULING         101
309 #endif
310   
311 # define        _PC_LINK_MAX            0
312 # define        _PC_MAX_CANON           1
313 # define        _PC_MAX_INPUT           2
314 # define        _PC_NAME_MAX            3
315 # define        _PC_PATH_MAX            4
316 # define        _PC_PIPE_BUF            5
317 # define        _PC_CHOWN_RESTRICTED    6
318 # define        _PC_NO_TRUNC            7
319 # define        _PC_VDISABLE            8
320 # define        _PC_ASYNC_IO            9
321 # define        _PC_PRIO_IO            10
322 # define        _PC_SYNC_IO            11
323 #ifdef __CYGWIN__
324 /* Ask for POSIX permission bits support. */
325 # define        _PC_POSIX_PERMISSIONS   90
326 /* Ask for full POSIX permission support including uid/gid settings. */
327 # define        _PC_POSIX_SECURITY     91
328 #endif
329
330 /* FIXME: This is temporary until winsup gets sorted out.  */
331 #ifdef __CYGWIN__
332 #define MAXPATHLEN (260 - 1 /* NUL */)
333 #else
334 # define        MAXPATHLEN      1024
335 #endif
336
337 #ifdef __cplusplus
338 }
339 #endif
340 #endif /* _SYS_UNISTD_H */