root/include/unistd.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef _UNISTD_H
   2 #define _UNISTD_H
   3 
   4 /* ok, this may be a joke, but I'm working on it */
   5 #define _POSIX_VERSION 198808L
   6 
   7 #define _POSIX_CHOWN_RESTRICTED 1    /* only root can do a chown (I think..) */
   8 #define _POSIX_NO_TRUNC         1    /* no pathname truncation (but see kernel) */
   9 #define _POSIX_VDISABLE         '\0' /* character to disable things like ^C */
  10 #define _POSIX_JOB_CONTROL      1
  11 #define _POSIX_SAVED_IDS        1    /* Implemented, for whatever good it is */
  12 
  13 #define STDIN_FILENO    0
  14 #define STDOUT_FILENO   1
  15 #define STDERR_FILENO   2
  16 
  17 #ifndef NULL
  18 #define NULL    ((void *)0)
  19 #endif
  20 
  21 /* access */
  22 #define F_OK    0
  23 #define X_OK    1
  24 #define W_OK    2
  25 #define R_OK    4
  26 
  27 /* lseek */
  28 #define SEEK_SET        0
  29 #define SEEK_CUR        1
  30 #define SEEK_END        2
  31 
  32 /* _SC stands for System Configuration. We don't use them much */
  33 #define _SC_ARG_MAX             1
  34 #define _SC_CHILD_MAX           2
  35 #define _SC_CLOCKS_PER_SEC      3
  36 #define _SC_NGROUPS_MAX         4
  37 #define _SC_OPEN_MAX            5
  38 #define _SC_JOB_CONTROL         6
  39 #define _SC_SAVED_IDS           7
  40 #define _SC_VERSION             8
  41 
  42 /* more (possibly) configurable things - now pathnames */
  43 #define _PC_LINK_MAX            1
  44 #define _PC_MAX_CANON           2
  45 #define _PC_MAX_INPUT           3
  46 #define _PC_NAME_MAX            4
  47 #define _PC_PATH_MAX            5
  48 #define _PC_PIPE_BUF            6
  49 #define _PC_NO_TRUNC            7
  50 #define _PC_VDISABLE            8
  51 #define _PC_CHOWN_RESTRICTED    9
  52 
  53 #if 0
  54 /* XXX - <sys/stat.h> illegally <sys/types.h> already.
  55  * The rest of these includes are also illegal (too much pollution).
  56  */
  57 #include <sys/types.h>
  58 #endif
  59 #include <sys/stat.h>
  60 #include <sys/time.h>
  61 #include <sys/times.h>
  62 #include <sys/utsname.h>
  63 #include <sys/resource.h>
  64 #include <utime.h>
  65 
  66 #ifdef __LIBRARY__
  67 
  68 #define __NR_setup      0       /* used only by init, to get system going */
  69 #define __NR_exit       1
  70 #define __NR_fork       2
  71 #define __NR_read       3
  72 #define __NR_write      4
  73 #define __NR_open       5
  74 #define __NR_close      6
  75 #define __NR_waitpid    7
  76 #define __NR_creat      8
  77 #define __NR_link       9
  78 #define __NR_unlink     10
  79 #define __NR_execve     11
  80 #define __NR_chdir      12
  81 #define __NR_time       13
  82 #define __NR_mknod      14
  83 #define __NR_chmod      15
  84 #define __NR_chown      16
  85 #define __NR_break      17
  86 #define __NR_stat       18
  87 #define __NR_lseek      19
  88 #define __NR_getpid     20
  89 #define __NR_mount      21
  90 #define __NR_umount     22
  91 #define __NR_setuid     23
  92 #define __NR_getuid     24
  93 #define __NR_stime      25
  94 #define __NR_ptrace     26
  95 #define __NR_alarm      27
  96 #define __NR_fstat      28
  97 #define __NR_pause      29
  98 #define __NR_utime      30
  99 #define __NR_stty       31
 100 #define __NR_gtty       32
 101 #define __NR_access     33
 102 #define __NR_nice       34
 103 #define __NR_ftime      35
 104 #define __NR_sync       36
 105 #define __NR_kill       37
 106 #define __NR_rename     38
 107 #define __NR_mkdir      39
 108 #define __NR_rmdir      40
 109 #define __NR_dup        41
 110 #define __NR_pipe       42
 111 #define __NR_times      43
 112 #define __NR_prof       44
 113 #define __NR_brk        45
 114 #define __NR_setgid     46
 115 #define __NR_getgid     47
 116 #define __NR_signal     48
 117 #define __NR_geteuid    49
 118 #define __NR_getegid    50
 119 #define __NR_acct       51
 120 #define __NR_phys       52
 121 #define __NR_lock       53
 122 #define __NR_ioctl      54
 123 #define __NR_fcntl      55
 124 #define __NR_mpx        56
 125 #define __NR_setpgid    57
 126 #define __NR_ulimit     58
 127 #define __NR_uname      59
 128 #define __NR_umask      60
 129 #define __NR_chroot     61
 130 #define __NR_ustat      62
 131 #define __NR_dup2       63
 132 #define __NR_getppid    64
 133 #define __NR_getpgrp    65
 134 #define __NR_setsid     66
 135 #define __NR_sigaction  67
 136 #define __NR_sgetmask   68
 137 #define __NR_ssetmask   69
 138 #define __NR_setreuid   70
 139 #define __NR_setregid   71
 140 #define __NR_sigsuspend 72
 141 #define __NR_sigpending 73
 142 #define __NR_sethostname 74
 143 #define __NR_setrlimit  75
 144 #define __NR_getrlimit  76
 145 #define __NR_getrusage  77
 146 #define __NR_gettimeofday 78
 147 #define __NR_settimeofday 79
 148 #define __NR_getgroups  80
 149 #define __NR_setgroups  81
 150 #define __NR_select     82
 151 #define __NR_symlink    83
 152 #define __NR_lstat      84
 153 #define __NR_readlink   85
 154 #define __NR_uselib     86
 155 #define __NR_swapon     87
 156 #define __NR_reboot     88
 157 #define __NR_readdir    89
 158 
 159 /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
 160 #define _syscall0(type,name) \
 161 type name(void) \
 162 { \
 163 long __res; \
 164 __asm__ volatile ("int $0x80" \
 165         : "=a" (__res) \
 166         : "0" (__NR_##name)); \
 167 if (__res >= 0) \
 168         return (type) __res; \
 169 errno = -__res; \
 170 return -1; \
 171 }
 172 
 173 #define _syscall1(type,name,atype,a) \
 174 type name(atype a) \
 175 { \
 176 long __res; \
 177 __asm__ volatile ("movl %2,%%ebx\n\t" \
 178         "int $0x80" \
 179         : "=a" (__res) \
 180         : "0" (__NR_##name),"g" ((long)(a)):"bx"); \
 181 if (__res >= 0) \
 182         return (type) __res; \
 183 errno = -__res; \
 184 return -1; \
 185 }
 186 
 187 #define _syscall2(type,name,atype,a,btype,b) \
 188 type name(atype a,btype b) \
 189 { \
 190 long __res; \
 191 __asm__ volatile ("movl %2,%%ebx\n\t" \
 192         "int $0x80" \
 193         : "=a" (__res) \
 194         : "0" (__NR_##name),"g" ((long)(a)),"c" ((long)(b)):"bx"); \
 195 if (__res >= 0) \
 196         return (type) __res; \
 197 errno = -__res; \
 198 return -1; \
 199 }
 200 
 201 #define _syscall3(type,name,atype,a,btype,b,ctype,c) \
 202 type name(atype a,btype b,ctype c) \
 203 { \
 204 long __res; \
 205 __asm__ volatile ("movl %2,%%ebx\n\t" \
 206         "int $0x80" \
 207         : "=a" (__res) \
 208         : "0" (__NR_##name),"g" ((long)(a)),"c" ((long)(b)),"d" ((long)(c)):"bx"); \
 209 if (__res>=0) \
 210         return (type) __res; \
 211 errno=-__res; \
 212 return -1; \
 213 }
 214 
 215 #endif /* __LIBRARY__ */
 216 
 217 /* XXX - illegal. */
 218 extern int errno;
 219 
 220 /* XXX - several non-POSIX functions here, and POSIX functions that are
 221  * supposed to be declared elsewhere.  Non-promotion of short types in
 222  * prototypes may cause trouble.  Arg names should be prefixed by
 223  * underscores.
 224  */
 225 int access(const char * filename, mode_t mode); /* XXX - short type */
 226 int acct(const char * filename);
 227 int brk(void * end_data_segment);
 228 /* XXX - POSIX says unsigned alarm(unsigned sec) */
 229 int alarm(int sec);
 230 void * sbrk(ptrdiff_t increment);
 231 int chdir(const char * filename);
 232 int chmod(const char * filename, mode_t mode);  /* XXX - short type */
 233 int chown(const char * filename, uid_t owner, gid_t group); /* XXX - shorts */
 234 int chroot(const char * filename);
 235 int close(int fildes);
 236 int creat(const char * filename, mode_t mode);  /* XXX - short type */
 237 int dup(int fildes);
 238 int execve(const char * filename, char ** argv, char ** envp);
 239 int execv(const char * pathname, char ** argv);
 240 int execvp(const char * file, char ** argv);
 241 int execl(const char * pathname, char * arg0, ...);
 242 int execlp(const char * file, char * arg0, ...);
 243 int execle(const char * pathname, char * arg0, ...);
 244 volatile void exit(int status);
 245 volatile void _exit(int status);
 246 int fcntl(int fildes, int cmd, ...);
 247 pid_t fork(void);
 248 pid_t getpid(void);
 249 uid_t getuid(void);
 250 uid_t geteuid(void);
 251 gid_t getgid(void);
 252 gid_t getegid(void);
 253 int ioctl(int fildes, int cmd, ...);
 254 int kill(pid_t pid, int signal);
 255 int link(const char * filename1, const char * filename2);
 256 off_t lseek(int fildes, off_t offset, int origin);
 257 int mknod(const char * filename, mode_t mode, dev_t dev); /* XXX - shorts */
 258 int mount(const char * specialfile, const char * dir, int rwflag);
 259 int nice(int val);
 260 int open(const char * filename, int flag, ...);
 261 int pause(void);
 262 int pipe(int * fildes);
 263 /* XXX**2 - POSIX says unsigned count */
 264 int read(int fildes, char * buf, off_t count);
 265 int setpgrp(void);
 266 int setpgid(pid_t pid,pid_t pgid);      /* XXX - short types */
 267 int setuid(uid_t uid);          /* XXX - short type */
 268 int setgid(gid_t gid);          /* XXX - short type */
 269 void (*signal(int sig, void (*fn)(int)))(int);
 270 int stat(const char * filename, struct stat * stat_buf);
 271 int fstat(int fildes, struct stat * stat_buf);
 272 int stime(time_t * tptr);
 273 int sync(void);
 274 time_t time(time_t * tloc);
 275 time_t times(struct tms * tbuf);
 276 int ulimit(int cmd, long limit);
 277 mode_t umask(mode_t mask);
 278 int umount(const char * specialfile);
 279 int uname(struct utsname * name);
 280 int unlink(const char * filename);
 281 int ustat(dev_t dev, struct ustat * ubuf);
 282 int utime(const char * filename, struct utimbuf * times);
 283 pid_t waitpid(pid_t pid,int * wait_stat,int options);
 284 pid_t wait(int * wait_stat);
 285 /* XXX**2 - POSIX says unsigned count */
 286 int write(int fildes, const char * buf, off_t count);
 287 int dup2(int oldfd, int newfd);
 288 int getppid(void);
 289 pid_t getpgrp(void);
 290 pid_t setsid(void);
 291 int sethostname(char *name, int len);
 292 int setrlimit(int resource, struct rlimit *rlp);
 293 int getrlimit(int resource, struct rlimit *rlp);
 294 int getrusage(int who, struct rusage *rusage);
 295 int gettimeofday(struct timeval *tv, struct timezone *tz);
 296 int settimeofday(struct timeval *tv, struct timezone *tz);
 297 int getgroups(int gidsetlen, gid_t *gidset);
 298 int setgroups(int gidsetlen, gid_t *gidset);
 299 int select(int width, fd_set * readfds, fd_set * writefds,
 300         fd_set * exceptfds, struct timeval * timeout);
 301 int swapon(const char * specialfile);
 302 #endif

/* [previous][next][first][last][top][bottom][index][help] */