1 |
1005 |
ivang |
#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 |
|
|
int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
|
24 |
|
|
#if defined(__CYGWIN__) || defined(__rtems__)
|
25 |
|
|
int _EXFUN(chroot, (const char *__path ));
|
26 |
|
|
#endif
|
27 |
|
|
int _EXFUN(close, (int __fildes ));
|
28 |
|
|
char _EXFUN(*ctermid, (char *__s ));
|
29 |
|
|
char _EXFUN(*cuserid, (char *__s ));
|
30 |
|
|
int _EXFUN(dup, (int __fildes ));
|
31 |
|
|
int _EXFUN(dup2, (int __fildes, int __fildes2 ));
|
32 |
|
|
#if defined(__CYGWIN__)
|
33 |
|
|
void _EXFUN(endusershell, (void));
|
34 |
|
|
#endif
|
35 |
|
|
int _EXFUN(execl, (const char *__path, const char *, ... ));
|
36 |
|
|
int _EXFUN(execle, (const char *__path, const char *, ... ));
|
37 |
|
|
int _EXFUN(execlp, (const char *__file, const char *, ... ));
|
38 |
|
|
int _EXFUN(execv, (const char *__path, char * const __argv[] ));
|
39 |
|
|
int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] ));
|
40 |
|
|
int _EXFUN(execvp, (const char *__file, char * const __argv[] ));
|
41 |
|
|
#if defined(__CYGWIN__) || defined(__rtems__)
|
42 |
|
|
int _EXFUN(fchdir, (int __fildes));
|
43 |
|
|
#endif
|
44 |
|
|
int _EXFUN(fchmod, (int __fildes, mode_t __mode ));
|
45 |
|
|
int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
|
46 |
|
|
pid_t _EXFUN(fork, (void ));
|
47 |
|
|
long _EXFUN(fpathconf, (int __fd, int __name ));
|
48 |
|
|
int _EXFUN(fsync, (int __fd));
|
49 |
|
|
char _EXFUN(*getcwd, (char *__buf, size_t __size ));
|
50 |
|
|
gid_t _EXFUN(getegid, (void ));
|
51 |
|
|
uid_t _EXFUN(geteuid, (void ));
|
52 |
|
|
gid_t _EXFUN(getgid, (void ));
|
53 |
|
|
int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] ));
|
54 |
|
|
char _EXFUN(*getlogin, (void ));
|
55 |
|
|
#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
|
56 |
|
|
int _EXFUN(getlogin_r, (char *name, size_t namesize) );
|
57 |
|
|
#endif
|
58 |
|
|
char _EXFUN(*getpass, (__const char *__prompt));
|
59 |
|
|
size_t _EXFUN(getpagesize, (void));
|
60 |
|
|
pid_t _EXFUN(getpgid, (pid_t));
|
61 |
|
|
pid_t _EXFUN(getpgrp, (void ));
|
62 |
|
|
pid_t _EXFUN(getpid, (void ));
|
63 |
|
|
pid_t _EXFUN(getppid, (void ));
|
64 |
|
|
uid_t _EXFUN(getuid, (void ));
|
65 |
|
|
#ifdef __CYGWIN__
|
66 |
|
|
char * _EXFUN(getusershell, (void));
|
67 |
|
|
char _EXFUN(*getwd, (char *__buf ));
|
68 |
|
|
int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser));
|
69 |
|
|
#endif
|
70 |
|
|
int _EXFUN(isatty, (int __fildes ));
|
71 |
|
|
int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
|
72 |
|
|
int _EXFUN(link, (const char *__path1, const char *__path2 ));
|
73 |
|
|
int _EXFUN(nice, (int __nice_value ));
|
74 |
|
|
off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
|
75 |
|
|
long _EXFUN(pathconf, (const char *__path, int __name ));
|
76 |
|
|
int _EXFUN(pause, (void ));
|
77 |
|
|
#ifdef __CYGWIN__
|
78 |
|
|
int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
|
79 |
|
|
#endif
|
80 |
|
|
int _EXFUN(pipe, (int __fildes[2] ));
|
81 |
|
|
_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
|
82 |
|
|
#if defined(__CYGWIN__)
|
83 |
|
|
int _EXFUN(revoke, (char *path));
|
84 |
|
|
#endif
|
85 |
|
|
int _EXFUN(rmdir, (const char *__path ));
|
86 |
|
|
#if defined(__CYGWIN__)
|
87 |
|
|
int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
|
88 |
|
|
#endif
|
89 |
|
|
#if defined(__rtems__)
|
90 |
|
|
void * _EXFUN(sbrk, (ptrdiff_t __incr));
|
91 |
|
|
#else
|
92 |
|
|
void * _EXFUN(sbrk, (size_t __incr));
|
93 |
|
|
#endif
|
94 |
|
|
#if defined(__CYGWIN__)
|
95 |
|
|
int _EXFUN(setegid, (gid_t __gid ));
|
96 |
|
|
int _EXFUN(seteuid, (uid_t __uid ));
|
97 |
|
|
#endif
|
98 |
|
|
int _EXFUN(setgid, (gid_t __gid ));
|
99 |
|
|
int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
|
100 |
|
|
int _EXFUN(setpgrp, (void ));
|
101 |
|
|
pid_t _EXFUN(setsid, (void ));
|
102 |
|
|
int _EXFUN(setuid, (uid_t __uid ));
|
103 |
|
|
#if defined(__CYGWIN__)
|
104 |
|
|
void _EXFUN(setusershell, (void));
|
105 |
|
|
#endif
|
106 |
|
|
unsigned _EXFUN(sleep, (unsigned int __seconds ));
|
107 |
|
|
void _EXFUN(swab, (const void *, void *, ssize_t));
|
108 |
|
|
long _EXFUN(sysconf, (int __name ));
|
109 |
|
|
pid_t _EXFUN(tcgetpgrp, (int __fildes ));
|
110 |
|
|
int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
|
111 |
|
|
char _EXFUN(*ttyname, (int __fildes ));
|
112 |
|
|
int _EXFUN(unlink, (const char *__path ));
|
113 |
|
|
int _EXFUN(vhangup, (void ));
|
114 |
|
|
_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
|
115 |
|
|
|
116 |
|
|
#ifndef _POSIX_SOURCE
|
117 |
|
|
pid_t _EXFUN(vfork, (void ));
|
118 |
|
|
#endif /* _POSIX_SOURCE */
|
119 |
|
|
|
120 |
|
|
/* Provide prototypes for most of the _<systemcall> names that are
|
121 |
|
|
provided in newlib for some compilers. */
|
122 |
|
|
int _EXFUN(_close, (int __fildes ));
|
123 |
|
|
pid_t _EXFUN(_fork, (void ));
|
124 |
|
|
pid_t _EXFUN(_getpid, (void ));
|
125 |
|
|
int _EXFUN(_link, (const char *__path1, const char *__path2 ));
|
126 |
|
|
off_t _EXFUN(_lseek, (int __fildes, off_t __offset, int __whence ));
|
127 |
|
|
_READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte ));
|
128 |
|
|
void * _EXFUN(_sbrk, (size_t __incr));
|
129 |
|
|
int _EXFUN(_unlink, (const char *__path ));
|
130 |
|
|
_READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nbyte ));
|
131 |
|
|
int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
|
132 |
|
|
|
133 |
|
|
#if defined(__CYGWIN__) || defined(__rtems__)
|
134 |
|
|
int _EXFUN(getdtablesize, (void));
|
135 |
|
|
int _EXFUN(setdtablesize, (int));
|
136 |
|
|
useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
|
137 |
|
|
unsigned _EXFUN(usleep, (unsigned int __useconds));
|
138 |
|
|
int _EXFUN(ftruncate, (int __fd, off_t __length));
|
139 |
|
|
int _EXFUN(truncate, (const char *, off_t __length));
|
140 |
|
|
#if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
|
141 |
|
|
/* winsock[2].h defines as __stdcall, and with int as 2nd arg */
|
142 |
|
|
int _EXFUN(gethostname, (char *__name, size_t __len));
|
143 |
|
|
#endif
|
144 |
|
|
char * _EXFUN(mktemp, (char *));
|
145 |
|
|
int _EXFUN(sync, (void));
|
146 |
|
|
int _EXFUN(readlink, (const char *__path, char *__buf, int __buflen));
|
147 |
|
|
int _EXFUN(symlink, (const char *__name1, const char *__name2));
|
148 |
|
|
#endif
|
149 |
|
|
|
150 |
|
|
#define F_OK 0
|
151 |
|
|
#define R_OK 4
|
152 |
|
|
#define W_OK 2
|
153 |
|
|
#define X_OK 1
|
154 |
|
|
|
155 |
|
|
# define SEEK_SET 0
|
156 |
|
|
# define SEEK_CUR 1
|
157 |
|
|
# define SEEK_END 2
|
158 |
|
|
|
159 |
|
|
#include <sys/features.h>
|
160 |
|
|
|
161 |
|
|
#define STDIN_FILENO 0 /* standard input file descriptor */
|
162 |
|
|
#define STDOUT_FILENO 1 /* standard output file descriptor */
|
163 |
|
|
#define STDERR_FILENO 2 /* standard error file descriptor */
|
164 |
|
|
|
165 |
|
|
/*
|
166 |
|
|
* 4.8.1 Get Configurable System Variables, P1003.1b-1993, p. 96
|
167 |
|
|
*
|
168 |
|
|
* NOTE: Table 4-2, Configurable System Variables, p. 96
|
169 |
|
|
*/
|
170 |
|
|
|
171 |
|
|
#define _SC_ARG_MAX 0
|
172 |
|
|
#define _SC_CHILD_MAX 1
|
173 |
|
|
#define _SC_CLK_TCK 2
|
174 |
|
|
#define _SC_NGROUPS_MAX 3
|
175 |
|
|
#define _SC_OPEN_MAX 4
|
176 |
|
|
/* no _SC_STREAM_MAX */
|
177 |
|
|
#define _SC_JOB_CONTROL 5
|
178 |
|
|
#define _SC_SAVED_IDS 6
|
179 |
|
|
#define _SC_VERSION 7
|
180 |
|
|
#define _SC_PAGESIZE 8
|
181 |
|
|
/* CYGWIN-specific values .. do not touch */
|
182 |
|
|
#define _SC_NPROCESSORS_CONF 9
|
183 |
|
|
#define _SC_NPROCESSORS_ONLN 10
|
184 |
|
|
#define _SC_PHYS_PAGES 11
|
185 |
|
|
#define _SC_AVPHYS_PAGES 12
|
186 |
|
|
/* end of CYGWIN-specific values */
|
187 |
|
|
#define _SC_MQ_OPEN_MAX 13
|
188 |
|
|
#define _SC_MQ_PRIO_MAX 14
|
189 |
|
|
#define _SC_RTSIG_MAX 15
|
190 |
|
|
#define _SC_SEM_NSEMS_MAX 16
|
191 |
|
|
#define _SC_SEM_VALUE_MAX 17
|
192 |
|
|
#define _SC_SIGQUEUE_MAX 18
|
193 |
|
|
#define _SC_TIMER_MAX 19
|
194 |
|
|
#define _SC_TZNAME_MAX 20
|
195 |
|
|
|
196 |
|
|
#define _SC_ASYNCHRONOUS_IO 21
|
197 |
|
|
#define _SC_FSYNC 22
|
198 |
|
|
#define _SC_MAPPED_FILES 23
|
199 |
|
|
#define _SC_MEMLOCK 24
|
200 |
|
|
#define _SC_MEMLOCK_RANGE 25
|
201 |
|
|
#define _SC_MEMORY_PROTECTION 26
|
202 |
|
|
#define _SC_MESSAGE_PASSING 27
|
203 |
|
|
#define _SC_PRIORITIZED_IO 28
|
204 |
|
|
#define _SC_REALTIME_SIGNALS 29
|
205 |
|
|
#define _SC_SEMAPHORES 30
|
206 |
|
|
#define _SC_SHARED_MEMORY_OBJECTS 31
|
207 |
|
|
#define _SC_SYNCHRONIZED_IO 32
|
208 |
|
|
#define _SC_TIMERS 33
|
209 |
|
|
#define _SC_AIO_LISTIO_MAX 34
|
210 |
|
|
#define _SC_AIO_MAX 35
|
211 |
|
|
#define _SC_AIO_PRIO_DELTA_MAX 36
|
212 |
|
|
#define _SC_DELAYTIMER_MAX 37
|
213 |
|
|
|
214 |
|
|
/*
|
215 |
|
|
* P1003.1c/D10, p. 52 adds the following.
|
216 |
|
|
*/
|
217 |
|
|
|
218 |
|
|
#define _SC_THREAD_KEYS_MAX 38
|
219 |
|
|
#define _SC_THREAD_STACK_MIN 39
|
220 |
|
|
#define _SC_THREAD_THREADS_MAX 40
|
221 |
|
|
#define _SC_TTY_NAME_MAX 41
|
222 |
|
|
|
223 |
|
|
#define _SC_THREADS 42
|
224 |
|
|
#define _SC_THREAD_ATTR_STACKADDR 43
|
225 |
|
|
#define _SC_THREAD_ATTR_STACKSIZE 44
|
226 |
|
|
#define _SC_THREAD_PRIORITY_SCHEDULING 45
|
227 |
|
|
#define _SC_THREAD_PRIO_INHERIT 46
|
228 |
|
|
/* _SC_THREAD_PRIO_PROTECT was _SC_THREAD_PRIO_CEILING in early drafts */
|
229 |
|
|
#define _SC_THREAD_PRIO_PROTECT 47
|
230 |
|
|
#define _SC_THREAD_PRIO_CEILING _SC_THREAD_PRIO_PROTECT
|
231 |
|
|
#define _SC_THREAD_PROCESS_SHARED 48
|
232 |
|
|
#define _SC_THREAD_SAFE_FUNCTIONS 49
|
233 |
|
|
#define _SC_GETGR_R_SIZE_MAX 50
|
234 |
|
|
#define _SC_GETPW_R_SIZE_MAX 51
|
235 |
|
|
#define _SC_LOGIN_NAME_MAX 52
|
236 |
|
|
#define _SC_THREAD_DESTRUCTOR_ITERATIONS 53
|
237 |
|
|
|
238 |
|
|
# define _PC_LINK_MAX 0
|
239 |
|
|
# define _PC_MAX_CANON 1
|
240 |
|
|
# define _PC_MAX_INPUT 2
|
241 |
|
|
# define _PC_NAME_MAX 3
|
242 |
|
|
# define _PC_PATH_MAX 4
|
243 |
|
|
# define _PC_PIPE_BUF 5
|
244 |
|
|
# define _PC_CHOWN_RESTRICTED 6
|
245 |
|
|
# define _PC_NO_TRUNC 7
|
246 |
|
|
# define _PC_VDISABLE 8
|
247 |
|
|
# define _PC_ASYNC_IO 9
|
248 |
|
|
# define _PC_PRIO_IO 10
|
249 |
|
|
# define _PC_SYNC_IO 11
|
250 |
|
|
#ifdef __CYGWIN__
|
251 |
|
|
/* Ask for POSIX permission bits support. */
|
252 |
|
|
# define _PC_POSIX_PERMISSIONS 90
|
253 |
|
|
/* Ask for full POSIX permission support including uid/gid settings. */
|
254 |
|
|
# define _PC_POSIX_SECURITY 91
|
255 |
|
|
#endif
|
256 |
|
|
|
257 |
|
|
/* FIXME: This is temporary until winsup gets sorted out. */
|
258 |
|
|
#ifdef __CYGWIN__
|
259 |
|
|
#define MAXPATHLEN (260 - 1 /* NUL */)
|
260 |
|
|
#else
|
261 |
|
|
# define MAXPATHLEN 1024
|
262 |
|
|
#endif
|
263 |
|
|
|
264 |
|
|
#ifdef __cplusplus
|
265 |
|
|
}
|
266 |
|
|
#endif
|
267 |
|
|
#endif /* _SYS_UNISTD_H */
|