source: trunk/src/emx/include/unistd.h@ 1330

Last change on this file since 1330 was 1312, checked in by bird, 21 years ago

Added lseek() args L_SET, L_INCR, L_XTND, and the POSIX versions SEEK_SET, SEEK_CUR, SEEK_END.

  • Property cvs2svn:cvs-rev set to 1.15
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 16.7 KB
Line 
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)unistd.h 8.12 (Berkeley) 4/27/95
34 * $FreeBSD: src/include/unistd.h,v 1.66 2002/12/29 01:07:55 mike Exp $
35 */
36
37/** @file
38 * EMX/FreeBSD 5.1
39 *
40 * @changed Commented out stuff which isn't implemented, TCPIP stuff at bottom.
41 * @todo Several man-years.. ;) Serious, complete the FreeBSD 5.1 merge and
42 * implement all the functions. Currently there is a bunch of POSIX
43 * #defines missing.
44 */
45
46#ifndef _UNISTD_H_
47#define _UNISTD_H_
48#define _UNISTD_H /* bird: emx */
49
50
51#include <sys/cdefs.h>
52#include <sys/types.h> /* XXX adds too much pollution. */
53/** @todo port FreeBSD sys/unistd.h: #include <sys/unistd.h> */
54#include <sys/_types.h>
55
56#if !defined(_GID_T_DECLARED) && !defined(_GID_T) /* bird: emx */
57typedef __gid_t gid_t; /* group id */
58#define _GID_T_DECLARED
59#define _GID_T /* bird: emx */
60#endif
61
62#if !defined(_OFF_T_DECLARED) && !defined(_OFF_T) /* bird:emx */
63typedef __off_t off_t; /* file offset */
64#define _OFF_T_DECLARED
65#define _OFF_T /* bird: emx */
66#endif
67
68#if !defined(_PID_T_DECLARED) && !defined(_PID_T) /* bird:emx */
69typedef __pid_t pid_t; /* process id */
70#define _PID_T_DECLARED
71#define _PID_T /* bird: emx */
72#endif
73
74#if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: emx */
75typedef __size_t size_t;
76#define _SIZE_T_DECLARED
77#define _SIZE_T /* bird: emx */
78#endif
79
80#if !defined(_SSIZE_T_DECLARED) && !defined(_SSIZE_T) /* bird: emx */
81typedef __ssize_t ssize_t;
82#define _SSIZE_T_DECLARED
83#define _SSIZE_T /* bird: emx */
84#endif
85
86#if !defined(_UID_T_DECLARED) && !defined(_UID_T) /* bird: emx */
87typedef __uid_t uid_t; /* user id */
88#define _UID_T_DECLARED
89#define _UID_T /* bird: emx */
90#endif
91
92#ifndef _USECONDS_T_DECLARED
93typedef __useconds_t useconds_t; /* microseconds (unsigned) */
94#define _USECONDS_T_DECLARED
95#endif
96
97#if !defined(STDIN_FILENO) /* bird: emx */
98#define STDIN_FILENO 0 /* standard input file descriptor */
99#define STDOUT_FILENO 1 /* standard output file descriptor */
100#define STDERR_FILENO 2 /* standard error file descriptor */
101#endif
102
103#ifndef NULL
104#define NULL 0 /* null pointer constant */
105#endif
106
107#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
108#define F_ULOCK 0 /* unlock locked section */
109#define F_LOCK 1 /* lock a section for exclusive use */
110#define F_TLOCK 2 /* test and lock a section for exclusive use */
111#define F_TEST 3 /* test a section for locks by other procs */
112#endif
113
114
115/** @todo: big todo to get in all the POSIX defines. */
116
117/* whence values for lseek(2) */
118#ifndef SEEK_SET
119#define SEEK_SET 0 /* set file offset to offset */
120#define SEEK_CUR 1 /* set file offset to current plus offset */
121#define SEEK_END 2 /* set file offset to EOF plus offset */
122#endif
123
124#ifndef _POSIX_SOURCE
125/* whence values for lseek(2); renamed by POSIX 1003.1 */
126#define L_SET SEEK_SET
127#define L_INCR SEEK_CUR
128#define L_XTND SEEK_END
129#endif
130
131#if !defined (F_OK)
132#define F_OK 0
133#define X_OK 1
134#define W_OK 2
135#define R_OK 4
136#endif
137
138#if !defined (SEEK_SET)
139#define SEEK_SET 0
140#define SEEK_CUR 1
141#define SEEK_END 2
142#endif
143
144#if !defined (_PC_LINK_MAX)
145#define _PC_LINK_MAX 1
146#define _PC_MAX_CANON 2
147#define _PC_MAX_INPUT 3
148#define _PC_NAME_MAX 4
149#define _PC_PATH_MAX 5
150#define _PC_PIPE_BUF 6
151#define _PC_CHOWN_RESTRICTED 7
152#define _PC_NO_TRUNC 8
153#define _PC_VDISABLE 9
154#endif
155
156#if !defined (_SC_ARG_MAX)
157#define _SC_ARG_MAX 1
158#define _SC_CHILD_MAX 2
159#define _SC_CLK_TCK 3
160#define _SC_NGROUPS_MAX 4
161#define _SC_OPEN_MAX 5
162#define _SC_STREAM_MAX 6
163#define _SC_TZNAME_MAX 7
164#define _SC_JOB_CONTROL 8
165#define _SC_SAVED_IDS 9
166#define _SC_VERSION 10
167#endif
168
169#if !defined (_POSIX_VERSION)
170#define _POSIX_VERSION 199009L
171#endif
172
173
174__BEGIN_DECLS
175/* 1003.1-1990 */
176void _exit(int) __dead2;
177int access(const char *, int);
178unsigned int alarm(unsigned int);
179int chdir(const char *);
180/** @todo int chown(const char *, uid_t, gid_t); */
181int close(int);
182char * cuserid(char *); /* bird: emx/todo/obosolete? */
183int dup(int);
184int dup2(int, int);
185/** @todo int eaccess(const char *, int); */
186int execl(const char *, const char *, ...);
187int execle(const char *, const char *, ...);
188int execlp(const char *, const char *, ...);
189int execv(const char *, char * const *);
190int execve(const char *, char * const *, char * const *);
191int execvp(const char *, char * const *);
192pid_t fork(void);
193long fpathconf(int, int);
194char *getcwd(char *, size_t);
195gid_t getegid(void);
196uid_t geteuid(void);
197gid_t getgid(void);
198int getgroups(int, gid_t []);
199char *getlogin(void);
200pid_t getpgrp(void);
201pid_t getpid(void);
202pid_t getppid(void);
203uid_t getuid(void);
204int isatty(int);
205/** @todo int link(const char *, const char *);*/
206#ifndef _LSEEK_DECLARED
207#define _LSEEK_DECLARED
208off_t lseek(int, off_t, int);
209#endif
210long pathconf(const char *, int);
211int pause(void);
212int pipe(int *);
213ssize_t read(int, void *, size_t);
214int rmdir(const char *);
215int setgid(gid_t);
216/** @todo void setproctitle(const char *_fmt, ...) __printf0like(1, 2); */
217int setpgid(pid_t, pid_t);
218pid_t setsid(void);
219int setuid(uid_t);
220unsigned sleep(unsigned);
221long sysconf(int);
222pid_t tcgetpgrp(int);
223int tcsetpgrp(int, pid_t);
224char *ttyname(int);
225int unlink(const char *);
226int write(int, const void *, size_t);
227
228/* 1003.2-1992 */
229#if __POSIX_VISIBLE >= 199209 || __XSI_VISIBLE
230/** @todo size_t confstr(int, char *, size_t);*/
231int getopt(int, char * const [], const char *);
232
233extern char *optarg; /* getopt(3) external variables */
234extern int optind, opterr, optopt;
235#endif
236
237/* ISO/IEC 9945-1: 1996 */
238#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
239int fsync(int);
240
241/*
242 * ftruncate() was in the POSIX Realtime Extension (it's used for shared
243 * memory), but truncate() was not.
244 */
245#ifndef _FTRUNCATE_DECLARED
246#define _FTRUNCATE_DECLARED
247int ftruncate(int, off_t);
248#endif
249#endif
250
251#if __POSIX_VISIBLE >= 199506
252/** @todo int getlogin_r(char *, int); */
253#endif
254
255/* 1003.1-2001 */
256#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
257/** @todo int fchown(int, uid_t, gid_t); */
258/** @todo int readlink(const char *, char *, int); */
259#endif
260#if __POSIX_VISIBLE >= 200112
261/* tcpip: int gethostname(char *, int / * socklen_t * /); */
262/** @todo int setegid(gid_t); */
263/** @todo int seteuid(uid_t); */
264#endif
265
266/*
267 * symlink() was originally in POSIX.1a, which was withdrawn after
268 * being overtaken by events (1003.1-2001). It was in XPG4.2, and of
269 * course has been in BSD since 4.2.
270 */
271#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 402 || __BSD_VISIBLE
272/** @todo int symlink(const char * __restrict, const char * __restrict); */
273#endif
274
275/* X/Open System Interfaces */
276#if __XSI_VISIBLE
277/** @todo char *crypt(const char *, const char *); */
278/** @todo char *ctermid(char *); */ /* XXX ??? */
279/** @todo int encrypt(char *, int); */
280/** @todo int fchdir(int); */
281/* tcpip: long gethostid(void); */
282/** @todo int getpgid(pid_t _pid); */
283/** @todo int getsid(pid_t _pid); */
284char *getwd(char *); /* LEGACY: obsoleted by getcwd() */
285/** @todo int lchown(const char *, uid_t, gid_t); */
286int lockf(int, int, off_t);
287/** @todo int nice(int); */
288/** @todo ssize_t pread(int, void *, size_t, off_t); */
289/** @todo ssize_t pwrite(int, const void *, size_t, off_t); */
290/** @todo int setpgrp(pid_t _pid, pid_t _pgrp); */ /* obsoleted by setpgid() */
291/** @todo int setregid(gid_t, gid_t); */
292/** @todo int setreuid(uid_t, uid_t); */
293/* void swab(const void * __restrict, void * __restrict, ssize_t); */
294/** @todo void sync(void); */
295/** @todo useconds_t ualarm(useconds_t, useconds_t); */
296int usleep(useconds_t);
297/** @todo pid_t vfork(void); */
298
299/* See comment at ftruncate() above. */
300#ifndef _TRUNCATE_DECLARED
301#define _TRUNCATE_DECLARED
302int truncate(const char *, off_t);
303#endif
304#endif /* __XSI_VISIBLE */
305
306#if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
307int brk(const void *);
308/** @todo int chroot(const char *); */
309/** @todo int getdtablesize(void); */
310int getpagesize(void) __pure2;
311char *getpass(const char *);
312char *_getpass1(const char *); /* bird: emx stuff */
313char *_getpass2(const char *, int); /* bird: emx stuff */
314void *sbrk(intptr_t);
315#endif
316
317#if __BSD_VISIBLE
318struct timeval; /* select(2) */
319/** @todo int acct(const char *); */
320/** @todo int async_daemon(void); */
321/** @todo int check_utility_compat(const char *); */
322/** @todo const char *
323 crypt_get_format(void); */
324/** @todo int crypt_set_format(const char *); */
325/** @todo int des_cipher(const char *, char *, long, int); */
326/** @todo int des_setkey(const char *key); */
327/** @todo void endusershell(void); */
328/** @todo int exect(const char *, char * const *, char * const *); */
329/** @todo char *fflagstostr(u_long); */
330/** @todo int getdomainname(char *, int); */
331/** @todo int getgrouplist(const char *, gid_t, gid_t *, int *); */
332/** @todo mode_t getmode(const void *, mode_t); */
333/** @todo int getpeereid(int, uid_t *, gid_t *); */
334/** @todo int getresgid(gid_t *, gid_t *, gid_t *); */
335/** @todo int getresuid(uid_t *, uid_t *, uid_t *); */
336/** @todo char *getusershell(void); */
337/** @todo int initgroups(const char *, gid_t); */
338/** @todo int iruserok(unsigned long, int, const char *, const char *); */
339/** @todo int iruserok_sa(const void *, int, int, const char *, const char *); */
340/** @todo int issetugid(void); */
341/** @todo char *mkdtemp(char *); */
342/** @todo int mknod(const char *, mode_t, dev_t); */
343#ifndef _MKSTEMP_DECLARED
344int mkstemp(char *);
345#define _MKSTEMP_DECLARED
346#endif
347/** @todo int mkstemps(char *, int); */
348#ifndef _MKTEMP_DECLARED
349char *mktemp(char *);
350#define _MKTEMP_DECLARED
351#endif
352/** @todo int nfsclnt(int, void *); */
353/** @todo int nfssvc(int, void *); */
354/** @todo int profil(char *, size_t, vm_offset_t, int); */
355/** @todo int rcmd(char **, int, const char *, const char *, const char *, int *); */
356/** @todo int rcmd_af(char **, int, const char *,
357 const char *, const char *, int *, int); */
358/** @todo int rcmdsh(char **, int, const char *,
359 const char *, const char *, const char *); */
360char *re_comp(const char *);
361int re_exec(const char *);
362/** @todo int reboot(int); */
363/** @todo int revoke(const char *); */
364/** @todo pid_t rfork(int); */
365/** @todo pid_t rfork_thread(int, void *, int (*)(void *), void *); */
366/** @todo int rresvport(int *); */
367/** @todo int rresvport_af(int *, int); */
368/** @todo int ruserok(const char *, int, const char *, const char *); */
369#if __BSD_VISIBLE
370#ifndef _SELECT_DECLARED
371#define _SELECT_DECLARED
372int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
373#endif
374#endif
375/** @todo int setdomainname(const char *, int); */
376/** @todo int setgroups(int, const gid_t *); */
377/** @todo void sethostid(long); */
378/** @todo int sethostname(const char *, int); */
379/** @todo #ifndef _SETKEY_DECLARED */
380/** @todo int setkey(const char *); */
381/** @todo #define _SETKEY_DECLARED */
382/** @todo #endif */
383/** @todo int setlogin(const char *); */
384/* crash with DOS: void *setmode(const char *); */
385/** @todo int setresgid(gid_t, gid_t, gid_t); */
386/** @todo int setresuid(uid_t, uid_t, uid_t); */
387/** @todo int setrgid(gid_t); */
388/** @todo int setruid(uid_t); */
389/** @todo void setusershell(void); */
390/** @todo int strtofflags(char **, u_long *, u_long *); */
391/** @todo int swapon(const char *); */
392/** @todo int swapoff(const char *); */
393/** @todo int syscall(int, ...); */
394/** @todo off_t __syscall(quad_t, ...); */
395/** @todo int ttyslot(void); */
396/** @todo int undelete(const char *); */
397/** @todo int unwhiteout(const char *); */
398/** @todo void *valloc(size_t); */ /* obsoleted by malloc() */
399
400/** @todo extern char *suboptarg; */ /* getsubopt(3) external variable */
401/** @todo #ifndef _GETSUBOPT_DECLARED */
402/** @todo int getsubopt(char **, char * const *, char **); */
403/** @todo #define _GETSUBOPT_DECLARED */
404/** @todo #endif */
405extern int optreset; /* getopt(3) external variable */
406#endif /* __BSD_VISIBLE */
407
408
409#if !defined(_POSIX_SOURCE)
410
411
412#endif
413
414
415#if !defined(_POSIX_SOURCE) || defined(_WITH_UNDERSCORE)
416/** @todo update this section to match the one without underscores as far as needed! */
417void __exit(int) __dead2;
418int _access(const char *, int);
419unsigned int _alarm(unsigned int);
420int _chdir(const char *);
421/** @todo int _chown(const char *, uid_t, gid_t); */
422int _close(int);
423char *_cuserid(char *);
424int _dup(int);
425int _dup2(int, int);
426/** @todo int _eaccess(const char *, int); */
427int _execl(const char *, const char *, ...);
428int _execle(const char *, const char *, ...);
429int _execlp(const char *, const char *, ...);
430int _execv(const char *, char * const *);
431int _execve(const char *, char * const *, char * const *);
432int _execvp(const char *, char * const *);
433pid_t _fork(void);
434long _fpathconf(int, int);
435char *_getcwd(char *, size_t);
436gid_t _getegid(void);
437uid_t _geteuid(void);
438gid_t _getgid(void);
439int _getgroups(int, gid_t []);
440char *_getlogin(void);
441pid_t _getpgrp(void);
442pid_t _getpid(void);
443pid_t _getppid(void);
444uid_t _getuid(void);
445int _isatty(int);
446/** @todo int _link(const char *, const char *);*/
447#ifndef __LSEEK_DECLARED
448#define __LSEEK_DECLARED
449off_t _lseek(int, off_t, int);
450#endif
451long _pathconf(const char *, int);
452int _pause(void);
453int _pipe(int *);
454ssize_t _read(int, void *, size_t);
455int _rmdir(const char *);
456int _setgid(gid_t);
457/** @todo void _setproctitle(const char *_fmt, ...) __printf0like(1, 2); */
458int _setpgid(pid_t, pid_t);
459pid_t _setsid(void);
460int _setuid(uid_t);
461unsigned _sleep(unsigned);
462long _sysconf(int);
463pid_t _tcgetpgrp(int);
464pid_t _tcsetpgrp(int, int);
465char *_ttyname(int);
466int _unlink(const char *);
467int _write(int, const void *, size_t);
468
469int _brk(const void *);
470char *_getpass(const char *);
471char *_getpass1(const char *);
472char *_getpass2(const char *, int);
473int _mkstemp(char *);
474char *_mktemp(char *);
475void *_sbrk(intptr_t);
476/** @todo int _profil(void *, unsigned, unsigned, unsigned); */
477
478/* 1003.2-1992 */
479extern char *_optarg;
480extern int _optind;
481extern int _opterr;
482extern int _optopt;
483int _getopt(int, char **, const char *);
484
485#endif
486
487/* Toolkit compatibility */
488#ifndef TCPCALL
489#define TCPCALL _System
490#endif
491
492#include <sys/cdefs.h>
493#include <sys/types.h>
494int TCPCALL soclose(int);
495#ifndef _POSIX_SOURCE
496int TCPCALL gethostid(void);
497int TCPCALL gethostname(char *, int);
498#ifndef TCPV40HDRS
499int TCPCALL iruserok(unsigned long, int, const char *, const char *);
500int TCPCALL rcmd(char **, int, const char *, const char *, const char *, int *);
501int TCPCALL rresvport(int *);
502int TCPCALL ruserok(const char *, int, const char *, const char *);
503#include <sys/select.h>
504#endif /* !TCP40HDRS */
505#endif /* !_POSIX_SOURCE */
506
507__END_DECLS
508
509#endif /* not _UNISTD_H */
Note: See TracBrowser for help on using the repository browser.