]> git.llucax.com Git - software/druntime.git/blob - import/stdc/posix/unistd.d
Applied all D2 changes to trunk. It should now be a fully functional D2 runtime.
[software/druntime.git] / import / stdc / posix / unistd.d
1 /**
2  * D header file for POSIX.
3  *
4  * Copyright: Public Domain
5  * License:   Public Domain
6  * Authors:   Sean Kelly
7  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8  */
9 module stdc.posix.unistd;
10
11 private import stdc.posix.config;
12 private import stdc.stddef;
13 public import stdc.posix.inttypes;  // for intptr_t
14 public import stdc.posix.sys.types; // for size_t, ssize_t, uid_t, gid_t, off_t, pid_t, useconds_t
15
16 extern (C):
17
18 const STDIN_FILENO  = 0;
19 const STDOUT_FILENO = 1;
20 const STDERR_FILENO = 2;
21
22 char*   optarg;
23 int     optind;
24 int     opterr;
25 int     optopt;
26
27 int     access(in char*, int);
28 uint    alarm(uint);
29 int     chdir(in char*);
30 int     chown(in char*, uid_t, gid_t);
31 int     close(int);
32 size_t  confstr(int, char*, size_t);
33 int     dup(int);
34 int     dup2(int, int);
35 int     execl(in char*, in char*, ...);
36 int     execle(in char*, in char*, ...);
37 int     execlp(in char*, in char*, ...);
38 int     execv(in char*, in char**);
39 int     execve(in char*, in char**, in char**);
40 int     execvp(in char*, in char**);
41 void    _exit(int);
42 int     fchown(int, uid_t, gid_t);
43 pid_t   fork();
44 c_long  fpathconf(int, int);
45 //int     ftruncate(int, off_t);
46 char*   getcwd(char*, size_t);
47 gid_t   getegid();
48 uid_t   geteuid();
49 gid_t   getgid();
50 int     getgroups(int, gid_t *);
51 int     gethostname(char*, size_t);
52 char*   getlogin();
53 int     getlogin_r(char*, size_t);
54 int     getopt(int, in char**, in char*);
55 pid_t   getpgrp();
56 pid_t   getpid();
57 pid_t   getppid();
58 uid_t   getuid();
59 int     isatty(int);
60 int     link(in char*, in char*);
61 //off_t   lseek(int, off_t, int);
62 c_long  pathconf(in char*, int);
63 int     pause();
64 int     pipe(int[2]);
65 ssize_t read(int, void*, size_t);
66 ssize_t readlink(in char*, char*, size_t);
67 int     rmdir(in char*);
68 int     setegid(gid_t);
69 int     seteuid(uid_t);
70 int     setgid(gid_t);
71 int     setpgid(pid_t, pid_t);
72 pid_t   setsid();
73 int     setuid(uid_t);
74 uint    sleep(uint);
75 int     symlink(in char*, in char*);
76 c_long  sysconf(int);
77 pid_t   tcgetpgrp(int);
78 int     tcsetpgrp(int, pid_t);
79 char*   ttyname(int);
80 int     ttyname_r(int, char*, size_t);
81 int     unlink(in char*);
82 ssize_t write(int, in void*, size_t);
83
84 version( linux )
85 {
86   static if( __USE_FILE_OFFSET64 )
87   {
88     off_t lseek64(int, off_t, int);
89     alias lseek64 lseek;
90   }
91   else
92   {
93     off_t lseek(int, off_t, int);
94   }
95   static if( __USE_LARGEFILE64 )
96   {
97     int   ftruncate64(int, off_t);
98     alias ftruncate64 ftruncate;
99   }
100   else
101   {
102     int   ftruncate(int, off_t);
103   }
104 }
105 else
106 {
107     off_t lseek(int, off_t, int);
108     int   ftruncate(int, off_t);
109 }
110
111 version( linux )
112 {
113     const F_OK          = 0;
114     const R_OK          = 4;
115     const W_OK          = 2;
116     const X_OK          = 1;
117
118     const F_ULOCK       = 0;
119     const F_LOCK        = 1;
120     const F_TLOCK       = 2;
121     const F_TEST        = 3;
122
123     enum
124     {
125         _CS_PATH,
126
127         _CS_V6_WIDTH_RESTRICTED_ENVS,
128
129         _CS_GNU_LIBC_VERSION,
130         _CS_GNU_LIBPTHREAD_VERSION,
131
132         _CS_LFS_CFLAGS = 1000,
133         _CS_LFS_LDFLAGS,
134         _CS_LFS_LIBS,
135         _CS_LFS_LINTFLAGS,
136         _CS_LFS64_CFLAGS,
137         _CS_LFS64_LDFLAGS,
138         _CS_LFS64_LIBS,
139         _CS_LFS64_LINTFLAGS,
140
141         _CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
142         _CS_XBS5_ILP32_OFF32_LDFLAGS,
143         _CS_XBS5_ILP32_OFF32_LIBS,
144         _CS_XBS5_ILP32_OFF32_LINTFLAGS,
145         _CS_XBS5_ILP32_OFFBIG_CFLAGS,
146         _CS_XBS5_ILP32_OFFBIG_LDFLAGS,
147         _CS_XBS5_ILP32_OFFBIG_LIBS,
148         _CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
149         _CS_XBS5_LP64_OFF64_CFLAGS,
150         _CS_XBS5_LP64_OFF64_LDFLAGS,
151         _CS_XBS5_LP64_OFF64_LIBS,
152         _CS_XBS5_LP64_OFF64_LINTFLAGS,
153         _CS_XBS5_LPBIG_OFFBIG_CFLAGS,
154         _CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
155         _CS_XBS5_LPBIG_OFFBIG_LIBS,
156         _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
157
158         _CS_POSIX_V6_ILP32_OFF32_CFLAGS,
159         _CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
160         _CS_POSIX_V6_ILP32_OFF32_LIBS,
161         _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
162         _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
163         _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
164         _CS_POSIX_V6_ILP32_OFFBIG_LIBS,
165         _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
166         _CS_POSIX_V6_LP64_OFF64_CFLAGS,
167         _CS_POSIX_V6_LP64_OFF64_LDFLAGS,
168         _CS_POSIX_V6_LP64_OFF64_LIBS,
169         _CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
170         _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
171         _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
172         _CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
173         _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS
174     }
175
176     enum
177     {
178         _PC_LINK_MAX,
179         _PC_MAX_CANON,
180         _PC_MAX_INPUT,
181         _PC_NAME_MAX,
182         _PC_PATH_MAX,
183         _PC_PIPE_BUF,
184         _PC_CHOWN_RESTRICTED,
185         _PC_NO_TRUNC,
186         _PC_VDISABLE,
187         _PC_SYNC_IO,
188         _PC_ASYNC_IO,
189         _PC_PRIO_IO,
190         _PC_SOCK_MAXBUF,
191         _PC_FILESIZEBITS,
192         _PC_REC_INCR_XFER_SIZE,
193         _PC_REC_MAX_XFER_SIZE,
194         _PC_REC_MIN_XFER_SIZE,
195         _PC_REC_XFER_ALIGN,
196         _PC_ALLOC_SIZE_MIN,
197         _PC_SYMLINK_MAX,
198         _PC_2_SYMLINKS
199     }
200
201     enum
202     {
203         _SC_ARG_MAX,
204         _SC_CHILD_MAX,
205         _SC_CLK_TCK,
206         _SC_NGROUPS_MAX,
207         _SC_OPEN_MAX,
208         _SC_STREAM_MAX,
209         _SC_TZNAME_MAX,
210         _SC_JOB_CONTROL,
211         _SC_SAVED_IDS,
212         _SC_REALTIME_SIGNALS,
213         _SC_PRIORITY_SCHEDULING,
214         _SC_TIMERS,
215         _SC_ASYNCHRONOUS_IO,
216         _SC_PRIORITIZED_IO,
217         _SC_SYNCHRONIZED_IO,
218         _SC_FSYNC,
219         _SC_MAPPED_FILES,
220         _SC_MEMLOCK,
221         _SC_MEMLOCK_RANGE,
222         _SC_MEMORY_PROTECTION,
223         _SC_MESSAGE_PASSING,
224         _SC_SEMAPHORES,
225         _SC_SHARED_MEMORY_OBJECTS,
226         _SC_AIO_LISTIO_MAX,
227         _SC_AIO_MAX,
228         _SC_AIO_PRIO_DELTA_MAX,
229         _SC_DELAYTIMER_MAX,
230         _SC_MQ_OPEN_MAX,
231         _SC_MQ_PRIO_MAX,
232         _SC_VERSION,
233         _SC_PAGESIZE,
234         _SC_PAGE_SIZE = _SC_PAGESIZE,
235         _SC_RTSIG_MAX,
236         _SC_SEM_NSEMS_MAX,
237         _SC_SEM_VALUE_MAX,
238         _SC_SIGQUEUE_MAX,
239         _SC_TIMER_MAX,
240
241         _SC_BC_BASE_MAX,
242         _SC_BC_DIM_MAX,
243         _SC_BC_SCALE_MAX,
244         _SC_BC_STRING_MAX,
245         _SC_COLL_WEIGHTS_MAX,
246         _SC_EQUIV_CLASS_MAX,
247         _SC_EXPR_NEST_MAX,
248         _SC_LINE_MAX,
249         _SC_RE_DUP_MAX,
250         _SC_CHARCLASS_NAME_MAX,
251
252         _SC_2_VERSION,
253         _SC_2_C_BIND,
254         _SC_2_C_DEV,
255         _SC_2_FORT_DEV,
256         _SC_2_FORT_RUN,
257         _SC_2_SW_DEV,
258         _SC_2_LOCALEDEF,
259
260         _SC_PII,
261         _SC_PII_XTI,
262         _SC_PII_SOCKET,
263         _SC_PII_INTERNET,
264         _SC_PII_OSI,
265         _SC_POLL,
266         _SC_SELECT,
267         _SC_UIO_MAXIOV,
268         _SC_IOV_MAX = _SC_UIO_MAXIOV,
269         _SC_PII_INTERNET_STREAM,
270         _SC_PII_INTERNET_DGRAM,
271         _SC_PII_OSI_COTS,
272         _SC_PII_OSI_CLTS,
273         _SC_PII_OSI_M,
274         _SC_T_IOV_MAX,
275
276         _SC_THREADS,
277         _SC_THREAD_SAFE_FUNCTIONS,
278         _SC_GETGR_R_SIZE_MAX,
279         _SC_GETPW_R_SIZE_MAX,
280         _SC_LOGIN_NAME_MAX,
281         _SC_TTY_NAME_MAX,
282         _SC_THREAD_DESTRUCTOR_ITERATIONS,
283         _SC_THREAD_KEYS_MAX,
284         _SC_THREAD_STACK_MIN,
285         _SC_THREAD_THREADS_MAX,
286         _SC_THREAD_ATTR_STACKADDR,
287         _SC_THREAD_ATTR_STACKSIZE,
288         _SC_THREAD_PRIORITY_SCHEDULING,
289         _SC_THREAD_PRIO_INHERIT,
290         _SC_THREAD_PRIO_PROTECT,
291         _SC_THREAD_PROCESS_SHARED,
292
293         _SC_NPROCESSORS_CONF,
294         _SC_NPROCESSORS_ONLN,
295         _SC_PHYS_PAGES,
296         _SC_AVPHYS_PAGES,
297         _SC_ATEXIT_MAX,
298         _SC_PASS_MAX,
299
300         _SC_XOPEN_VERSION,
301         _SC_XOPEN_XCU_VERSION,
302         _SC_XOPEN_UNIX,
303         _SC_XOPEN_CRYPT,
304         _SC_XOPEN_ENH_I18N,
305         _SC_XOPEN_SHM,
306
307         _SC_2_CHAR_TERM,
308         _SC_2_C_VERSION,
309         _SC_2_UPE,
310
311         _SC_XOPEN_XPG2,
312         _SC_XOPEN_XPG3,
313         _SC_XOPEN_XPG4,
314
315         _SC_CHAR_BIT,
316         _SC_CHAR_MAX,
317         _SC_CHAR_MIN,
318         _SC_INT_MAX,
319         _SC_INT_MIN,
320         _SC_LONG_BIT,
321         _SC_WORD_BIT,
322         _SC_MB_LEN_MAX,
323         _SC_NZERO,
324         _SC_SSIZE_MAX,
325         _SC_SCHAR_MAX,
326         _SC_SCHAR_MIN,
327         _SC_SHRT_MAX,
328         _SC_SHRT_MIN,
329         _SC_UCHAR_MAX,
330         _SC_UINT_MAX,
331         _SC_ULONG_MAX,
332         _SC_USHRT_MAX,
333
334         _SC_NL_ARGMAX,
335         _SC_NL_LANGMAX,
336         _SC_NL_MSGMAX,
337         _SC_NL_NMAX,
338         _SC_NL_SETMAX,
339         _SC_NL_TEXTMAX,
340
341         _SC_XBS5_ILP32_OFF32,
342         _SC_XBS5_ILP32_OFFBIG,
343         _SC_XBS5_LP64_OFF64,
344         _SC_XBS5_LPBIG_OFFBIG,
345
346         _SC_XOPEN_LEGACY,
347         _SC_XOPEN_REALTIME,
348         _SC_XOPEN_REALTIME_THREADS,
349
350         _SC_ADVISORY_INFO,
351         _SC_BARRIERS,
352         _SC_BASE,
353         _SC_C_LANG_SUPPORT,
354         _SC_C_LANG_SUPPORT_R,
355         _SC_CLOCK_SELECTION,
356         _SC_CPUTIME,
357         _SC_THREAD_CPUTIME,
358         _SC_DEVICE_IO,
359         _SC_DEVICE_SPECIFIC,
360         _SC_DEVICE_SPECIFIC_R,
361         _SC_FD_MGMT,
362         _SC_FIFO,
363         _SC_PIPE,
364         _SC_FILE_ATTRIBUTES,
365         _SC_FILE_LOCKING,
366         _SC_FILE_SYSTEM,
367         _SC_MONOTONIC_CLOCK,
368         _SC_MULTI_PROCESS,
369         _SC_SINGLE_PROCESS,
370         _SC_NETWORKING,
371         _SC_READER_WRITER_LOCKS,
372         _SC_SPIN_LOCKS,
373         _SC_REGEXP,
374         _SC_REGEX_VERSION,
375         _SC_SHELL,
376         _SC_SIGNALS,
377         _SC_SPAWN,
378         _SC_SPORADIC_SERVER,
379         _SC_THREAD_SPORADIC_SERVER,
380         _SC_SYSTEM_DATABASE,
381         _SC_SYSTEM_DATABASE_R,
382         _SC_TIMEOUTS,
383         _SC_TYPED_MEMORY_OBJECTS,
384         _SC_USER_GROUPS,
385         _SC_USER_GROUPS_R,
386         _SC_2_PBS,
387         _SC_2_PBS_ACCOUNTING,
388         _SC_2_PBS_LOCATE,
389         _SC_2_PBS_MESSAGE,
390         _SC_2_PBS_TRACK,
391         _SC_SYMLOOP_MAX,
392         _SC_STREAMS,
393         _SC_2_PBS_CHECKPOINT,
394
395         _SC_V6_ILP32_OFF32,
396         _SC_V6_ILP32_OFFBIG,
397         _SC_V6_LP64_OFF64,
398         _SC_V6_LPBIG_OFFBIG,
399
400         _SC_HOST_NAME_MAX,
401         _SC_TRACE,
402         _SC_TRACE_EVENT_FILTER,
403         _SC_TRACE_INHERIT,
404         _SC_TRACE_LOG,
405
406         _SC_LEVEL1_ICACHE_SIZE,
407         _SC_LEVEL1_ICACHE_ASSOC,
408         _SC_LEVEL1_ICACHE_LINESIZE,
409         _SC_LEVEL1_DCACHE_SIZE,
410         _SC_LEVEL1_DCACHE_ASSOC,
411         _SC_LEVEL1_DCACHE_LINESIZE,
412         _SC_LEVEL2_CACHE_SIZE,
413         _SC_LEVEL2_CACHE_ASSOC,
414         _SC_LEVEL2_CACHE_LINESIZE,
415         _SC_LEVEL3_CACHE_SIZE,
416         _SC_LEVEL3_CACHE_ASSOC,
417         _SC_LEVEL3_CACHE_LINESIZE,
418         _SC_LEVEL4_CACHE_SIZE,
419         _SC_LEVEL4_CACHE_ASSOC,
420         _SC_LEVEL4_CACHE_LINESIZE,
421
422         _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
423         _SC_RAW_SOCKETS
424     }
425 }
426 else version( darwin )
427 {
428     const F_OK          = 0;
429     const R_OK          = 4;
430     const W_OK          = 2;
431     const X_OK          = 1;
432
433     const F_ULOCK       = 0;
434     const F_LOCK        = 1;
435     const F_TLOCK       = 2;
436     const F_TEST        = 3;
437 }
438 else version( freebsd )
439 {
440     const F_OK          = 0;
441     const R_OK          = 0x04;
442     const W_OK          = 0x02;
443     const X_OK          = 0x01;
444
445     const F_ULOCK       = 0;
446     const F_LOCK        = 1;
447     const F_TLOCK       = 2;
448     const F_TEST        = 3;
449 }
450
451 //
452 // File Synchronization (FSC)
453 //
454 /*
455 int fsync(int);
456 */
457
458 //
459 // Synchronized I/O (SIO)
460 //
461 /*
462 int fdatasync(int);
463 */
464
465 //
466 // XOpen (XSI)
467 //
468 /*
469 char*      crypt(in char*, in char*);
470 char*      ctermid(char*);
471 void       encrypt(char[64], int);
472 int        fchdir(int);
473 c_long     gethostid();
474 pid_t      getpgid(pid_t);
475 pid_t      getsid(pid_t);
476 char*      getwd(char*); // LEGACY
477 int        lchown(in char*, uid_t, gid_t);
478 int        lockf(int, int, off_t);
479 int        nice(int);
480 ssize_t    pread(int, void*, size_t, off_t);
481 ssize_t    pwrite(int, in void*, size_t, off_t);
482 pid_t      setpgrp();
483 int        setregid(gid_t, gid_t);
484 int        setreuid(uid_t, uid_t);
485 void       swab(in void*, void*, ssize_t);
486 void       sync();
487 int        truncate(in char*, off_t);
488 useconds_t ualarm(useconds_t, useconds_t);
489 int        usleep(useconds_t);
490 pid_t      vfork();
491 */
492
493 version( linux )
494 {
495     char*      crypt(in char*, in char*);
496     char*      ctermid(char*);
497     void       encrypt(char[64], int);
498     int        fchdir(int);
499     c_long     gethostid();
500     pid_t      getpgid(pid_t);
501     pid_t      getsid(pid_t);
502     char*      getwd(char*); // LEGACY
503     int        lchown(in char*, uid_t, gid_t);
504     //int        lockf(int, int, off_t);
505     int        nice(int);
506     //ssize_t    pread(int, void*, size_t, off_t);
507     //ssize_t    pwrite(int, in void*, size_t, off_t);
508     pid_t      setpgrp();
509     int        setregid(gid_t, gid_t);
510     int        setreuid(uid_t, uid_t);
511     void       swab(in void*, void*, ssize_t);
512     void       sync();
513     //int        truncate(in char*, off_t);
514     useconds_t ualarm(useconds_t, useconds_t);
515     int        usleep(useconds_t);
516     pid_t      vfork();
517
518   static if( __USE_LARGEFILE64 )
519   {
520     int        lockf64(int, int, off_t);
521     alias      lockf64 lockf;
522
523     ssize_t    pread64(int, void*, size_t, off_t);
524     alias      pread64 pread;
525
526     ssize_t    pwrite64(int, in void*, size_t, off_t);
527     alias      pwrite64 pwrite;
528
529     int        truncate64(in char*, off_t);
530     alias      truncate64 truncate;
531   }
532   else
533   {
534     int        lockf(int, int, off_t);
535     ssize_t    pread(int, void*, size_t, off_t);
536     ssize_t    pwrite(int, in void*, size_t, off_t);
537     int        truncate(in char*, off_t);
538   }
539 }
540 else version (darwin)
541 {
542     char*      crypt(in char*, in char*);
543     char*      ctermid(char*);
544     void       encrypt(char[64], int);
545     int        fchdir(int);
546     c_long     gethostid();
547     pid_t      getpgid(pid_t);
548     pid_t      getsid(pid_t);
549     char*      getwd(char*); // LEGACY
550     int        lchown(in char*, uid_t, gid_t);
551     int        lockf(int, int, off_t);
552     int        nice(int);
553     ssize_t    pread(int, void*, size_t, off_t);
554     ssize_t    pwrite(int, in void*, size_t, off_t);
555     pid_t      setpgrp();
556     int        setregid(gid_t, gid_t);
557     int        setreuid(uid_t, uid_t);
558     void       swab(in void*, void*, ssize_t);
559     void       sync();
560     int        truncate(in char*, off_t);
561     useconds_t ualarm(useconds_t, useconds_t);
562     int        usleep(useconds_t);
563     pid_t      vfork();
564 }
565 else version (freebsd)
566 {
567     char*      crypt(in char*, in char*);
568     //char*      ctermid(char*);
569     void       encrypt(char*, int);
570     int        fchdir(int);
571     c_long     gethostid();
572     int        getpgid(pid_t);
573     int        getsid(pid_t);
574     char*      getwd(char*); // LEGACY
575     int        lchown(in char*, uid_t, gid_t);
576     int        lockf(int, int, off_t);
577     int        nice(int);
578     ssize_t    pread(int, void*, size_t, off_t);
579     ssize_t    pwrite(int, in void*, size_t, off_t);
580     int        setpgrp(pid_t, pid_t);
581     int        setregid(gid_t, gid_t);
582     int        setreuid(uid_t, uid_t);
583     void       swab(in void*, void*, ssize_t);
584     void       sync();
585     int        truncate(in char*, off_t);
586     useconds_t ualarm(useconds_t, useconds_t);
587     int        usleep(useconds_t);
588     pid_t      vfork();
589 }