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

Last change on this file since 521 was 358, checked in by bird, 22 years ago

#427: Rough merge of emx and FreeBSD 5.1 unistd.h

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