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

Last change on this file since 706 was 684, checked in by bird, 22 years ago

#634: Added lockf() declaration and #defines.

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