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

Last change on this file since 1567 was 1560, checked in by bird, 21 years ago

initgroups, getgrouplist, valloc, memalign.

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