OSDN Git Service

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