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