2 * D header file for POSIX.
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
10 /* Copyright Sean Kelly 2005 - 2009.
11 * Distributed under the Boost Software License, Version 1.0.
12 * (See accompanying file LICENSE or copy at
13 * http://www.boost.org/LICENSE_1_0.txt)
15 module core.sys.posix.stdlib;
17 import core.sys.posix.config;
18 public import core.stdc.stdlib;
19 public import core.sys.posix.sys.wait;
27 else version (WatchOS)
37 // Required (defined in core.stdc.stdlib)
54 int atexit(void function());
55 double atof(const scope char*);
56 int atoi(const scope char*);
57 c_long atol(const scope char*);
58 long atoll(const scope char*);
59 void* bsearch(const scope void*, const scope void*, size_t, size_t, int function(const scope void*, const scope void*));
60 void* calloc(size_t, size_t);
64 char* getenv(const scope char*);
66 ldiv_t ldiv(c_long, c_long);
68 lldiv_t lldiv(long, long);
70 int mblen(const scope char*, size_t);
71 size_t mbstowcs(wchar_t*, const scope char*, size_t);
72 int mbtowc(wchar_t*, const scope char*, size_t);
73 void qsort(void*, size_t, size_t, int function(const scope void*, const scope void*));
75 void* realloc(void*, size_t);
77 double strtod(const scope char*, char**);
78 float strtof(const scope char*, char**);
79 c_long strtol(const scope char*, char**, int);
80 real strtold(const scope char*, char**);
81 long strtoll(const scope char*, char**, int);
82 c_ulong strtoul(const scope char*, char**, int);
83 ulong strtoull(const scope char*, char**, int);
84 int system(const scope char*);
85 size_t wcstombs(char*, const scope wchar_t*, size_t);
86 int wctomb(char*, wchar_t);
90 // Advisory Information (ADV)
93 int posix_memalign(void**, size_t, size_t);
96 version (CRuntime_Glibc)
98 int posix_memalign(scope void**, size_t, size_t) pure;
100 else version (FreeBSD)
102 int posix_memalign(scope void**, size_t, size_t) pure;
104 else version (NetBSD)
106 int posix_memalign(scope void**, size_t, size_t) pure;
108 else version (OpenBSD)
110 int posix_memalign(scope void**, size_t, size_t) pure;
112 else version (DragonFlyBSD)
114 int posix_memalign(scope void**, size_t, size_t) pure;
116 else version (Solaris)
118 int posix_memalign(scope void**, size_t, size_t) pure;
120 else version (Darwin)
122 int posix_memalign(scope void**, size_t, size_t) pure;
124 else version (CRuntime_Bionic)
126 // Added since Lollipop
127 int posix_memalign(scope void**, size_t, size_t) pure;
129 else version (CRuntime_Musl)
131 int posix_memalign(scope void**, size_t, size_t) pure;
133 else version (CRuntime_UClibc)
135 int posix_memalign(scope void**, size_t, size_t) pure;
142 int setenv(const scope char*, const scope char*, int);
143 int unsetenv(const scope char*);
146 version (CRuntime_Glibc)
148 int setenv(const scope char*, const scope char*, int);
149 int unsetenv(const scope char*);
151 void* valloc(size_t); // LEGACY non-standard
153 else version (Darwin)
155 int setenv(const scope char*, const scope char*, int);
156 int unsetenv(const scope char*);
158 void* valloc(size_t); // LEGACY non-standard
160 else version (FreeBSD)
162 int setenv(const scope char*, const scope char*, int);
163 int unsetenv(const scope char*);
165 void* valloc(size_t); // LEGACY non-standard
167 else version (NetBSD)
169 int setenv(const scope char*, const scope char*, int);
170 int __unsetenv13(const scope char*);
171 alias __unsetenv13 unsetenv;
172 void* valloc(size_t); // LEGACY non-standard
174 else version (OpenBSD)
176 int setenv(const scope char*, const scope char*, int);
177 int unsetenv(const scope char*);
179 void* valloc(size_t); // LEGACY non-standard
181 else version (DragonFlyBSD)
183 int setenv(const scope char*, const scope char*, int);
184 int unsetenv(const scope char*);
186 void* valloc(size_t); // LEGACY non-standard
188 else version (CRuntime_Bionic)
190 int setenv(const scope char*, const scope char*, int);
191 int unsetenv(const scope char*);
193 void* valloc(size_t);
195 else version (Solaris)
197 int setenv(const scope char*, const scope char*, int);
198 int unsetenv(const scope char*);
200 void* valloc(size_t); // LEGACY non-standard
202 else version (CRuntime_Musl)
204 int setenv(const scope char*, const scope char*, int);
205 int unsetenv(const scope char*);
207 else version (CRuntime_UClibc)
209 int setenv(const scope char*, const scope char*, int);
210 int unsetenv(const scope char*);
211 void* valloc(size_t);
215 // Thread-Safe Functions (TSF)
221 version (CRuntime_Glibc)
225 else version (Darwin)
229 else version (FreeBSD)
233 else version (NetBSD)
237 else version (OpenBSD)
241 else version (DragonFlyBSD)
245 else version (Solaris)
249 else version (CRuntime_UClibc)
258 WNOHANG (defined in core.sys.posix.sys.wait)
259 WUNTRACED (defined in core.sys.posix.sys.wait)
260 WEXITSTATUS (defined in core.sys.posix.sys.wait)
261 WIFEXITED (defined in core.sys.posix.sys.wait)
262 WIFSIGNALED (defined in core.sys.posix.sys.wait)
263 WIFSTOPPED (defined in core.sys.posix.sys.wait)
264 WSTOPSIG (defined in core.sys.posix.sys.wait)
265 WTERMSIG (defined in core.sys.posix.sys.wait)
267 c_long a64l(const scope char*);
269 char* ecvt(double, int, int *, int *); // LEGACY
270 double erand48(ref ushort[3]);
271 char* fcvt(double, int, int *, int *); // LEGACY
272 char* gcvt(double, int, char*); // LEGACY
273 // per spec: int getsubopt(char** char* const*, char**);
274 int getsubopt(char**, const scope char**, char**);
276 char* initstate(uint, char*, size_t);
277 c_long jrand48(ref ushort[3]);
279 void lcong48(ref ushort[7]);
281 char* mktemp(char*); // LEGACY
283 int mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
285 c_long nrand48(ref ushort[3]);
286 int posix_openpt(int);
290 char* realpath(const scope char*, char*);
291 ushort *seed48(ref ushort[3]);
292 void setkey(const scope char*);
293 char* setstate(const scope char*);
294 void srand48(c_long);
299 version (CRuntime_Glibc)
301 //WNOHANG (defined in core.sys.posix.sys.wait)
302 //WUNTRACED (defined in core.sys.posix.sys.wait)
303 //WEXITSTATUS (defined in core.sys.posix.sys.wait)
304 //WIFEXITED (defined in core.sys.posix.sys.wait)
305 //WIFSIGNALED (defined in core.sys.posix.sys.wait)
306 //WIFSTOPPED (defined in core.sys.posix.sys.wait)
307 //WSTOPSIG (defined in core.sys.posix.sys.wait)
308 //WTERMSIG (defined in core.sys.posix.sys.wait)
310 c_long a64l(const scope char*);
312 char* ecvt(double, int, int *, int *); // LEGACY
313 double erand48(ref ushort[3]);
314 char* fcvt(double, int, int *, int *); // LEGACY
315 char* gcvt(double, int, char*); // LEGACY
316 int getsubopt(char**, const scope char**, char**);
318 char* initstate(uint, char*, size_t);
319 c_long jrand48(ref ushort[3]);
321 void lcong48(ref ushort[7]);
323 char* mktemp(char*); // LEGACY
324 //int mkstemp(char*);
325 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
327 c_long nrand48(ref ushort[3]);
328 int posix_openpt(int);
332 char* realpath(const scope char*, char*);
333 ushort *seed48(ref ushort[3]);
334 void setkey(const scope char*);
335 char* setstate(const scope char*);
336 void srand48(c_long);
340 static if ( __USE_LARGEFILE64 )
342 int mkstemp64(char*);
343 alias mkstemp64 mkstemp;
350 else version (Darwin)
352 //WNOHANG (defined in core.sys.posix.sys.wait)
353 //WUNTRACED (defined in core.sys.posix.sys.wait)
354 //WEXITSTATUS (defined in core.sys.posix.sys.wait)
355 //WIFEXITED (defined in core.sys.posix.sys.wait)
356 //WIFSIGNALED (defined in core.sys.posix.sys.wait)
357 //WIFSTOPPED (defined in core.sys.posix.sys.wait)
358 //WSTOPSIG (defined in core.sys.posix.sys.wait)
359 //WTERMSIG (defined in core.sys.posix.sys.wait)
361 c_long a64l(const scope char*);
363 char* ecvt(double, int, int *, int *); // LEGACY
364 double erand48(ref ushort[3]);
365 char* fcvt(double, int, int *, int *); // LEGACY
366 char* gcvt(double, int, char*); // LEGACY
367 int getsubopt(char**, const scope char**, char**);
369 char* initstate(uint, char*, size_t);
370 c_long jrand48(ref ushort[3]);
372 void lcong48(ref ushort[7]);
374 char* mktemp(char*); // LEGACY
376 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
378 c_long nrand48(ref ushort[3]);
379 int posix_openpt(int);
383 char* realpath(const scope char*, char*);
384 ushort *seed48(ref ushort[3]);
385 void setkey(const scope char*);
386 char* setstate(const scope char*);
387 void srand48(c_long);
391 else version (FreeBSD)
393 //WNOHANG (defined in core.sys.posix.sys.wait)
394 //WUNTRACED (defined in core.sys.posix.sys.wait)
395 //WEXITSTATUS (defined in core.sys.posix.sys.wait)
396 //WIFEXITED (defined in core.sys.posix.sys.wait)
397 //WIFSIGNALED (defined in core.sys.posix.sys.wait)
398 //WIFSTOPPED (defined in core.sys.posix.sys.wait)
399 //WSTOPSIG (defined in core.sys.posix.sys.wait)
400 //WTERMSIG (defined in core.sys.posix.sys.wait)
402 c_long a64l(const scope char*);
404 //char* ecvt(double, int, int *, int *); // LEGACY
405 double erand48(ref ushort[3]);
406 //char* fcvt(double, int, int *, int *); // LEGACY
407 //char* gcvt(double, int, char*); // LEGACY
408 int getsubopt(char**, const scope char**, char**);
410 char* initstate(uint, char*, size_t);
411 c_long jrand48(ref ushort[3]);
413 void lcong48(ref ushort[7]);
415 char* mktemp(char*); // LEGACY
417 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
419 c_long nrand48(ref ushort[3]);
420 int posix_openpt(int);
424 char* realpath(const scope char*, char*);
425 ushort *seed48(ref ushort[3]);
426 void setkey(const scope char*);
427 char* setstate(const scope char*);
428 void srand48(c_long);
432 else version (NetBSD)
434 //WNOHANG (defined in core.sys.posix.sys.wait)
435 //WUNTRACED (defined in core.sys.posix.sys.wait)
436 //WEXITSTATUS (defined in core.sys.posix.sys.wait)
437 //WIFEXITED (defined in core.sys.posix.sys.wait)
438 //WIFSIGNALED (defined in core.sys.posix.sys.wait)
439 //WIFSTOPPED (defined in core.sys.posix.sys.wait)
440 //WSTOPSIG (defined in core.sys.posix.sys.wait)
441 //WTERMSIG (defined in core.sys.posix.sys.wait)
443 c_long a64l(const scope char*);
445 //char* ecvt(double, int, int *, int *); // LEGACY
446 double erand48(ref ushort[3]);
447 //char* fcvt(double, int, int *, int *); // LEGACY
448 //char* gcvt(double, int, char*); // LEGACY
449 int getsubopt(char**, const scope char**, char**);
451 char* initstate(uint, char*, size_t);
452 c_long jrand48(ref ushort[3]);
454 void lcong48(ref ushort[7]);
456 char* mktemp(char*); // LEGACY
458 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
460 c_long nrand48(ref ushort[3]);
461 int posix_openpt(int);
465 char* realpath(const scope char*, char*);
466 ushort *seed48(ref ushort[3]);
467 void setkey(const scope char*);
468 char* setstate(const scope char*);
469 void srand48(c_long);
473 else version (OpenBSD)
475 //WNOHANG (defined in core.sys.posix.sys.wait)
476 //WUNTRACED (defined in core.sys.posix.sys.wait)
477 //WEXITSTATUS (defined in core.sys.posix.sys.wait)
478 //WIFEXITED (defined in core.sys.posix.sys.wait)
479 //WIFSIGNALED (defined in core.sys.posix.sys.wait)
480 //WIFSTOPPED (defined in core.sys.posix.sys.wait)
481 //WSTOPSIG (defined in core.sys.posix.sys.wait)
482 //WTERMSIG (defined in core.sys.posix.sys.wait)
484 c_long a64l(const scope char*);
486 //char* ecvt(double, int, int *, int *); // LEGACY
487 double erand48(ref ushort[3]);
488 //char* fcvt(double, int, int *, int *); // LEGACY
489 //char* gcvt(double, int, char*); // LEGACY
490 int getsubopt(char**, const scope char**, char**);
492 char* initstate(uint, char*, size_t);
493 c_long jrand48(ref ushort[3]);
495 void lcong48(ref ushort[7]);
497 char* mktemp(char*); // LEGACY
499 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
501 c_long nrand48(ref ushort[3]);
502 int posix_openpt(int);
506 char* realpath(const scope char*, char*);
507 ushort *seed48(ref ushort[3]);
508 // void setkey(const scope char*); // not implemented
509 char* setstate(const scope char*);
510 void srand48(c_long);
514 else version (DragonFlyBSD)
516 //WNOHANG (defined in core.sys.posix.sys.wait)
517 //WUNTRACED (defined in core.sys.posix.sys.wait)
518 //WEXITSTATUS (defined in core.sys.posix.sys.wait)
519 //WIFEXITED (defined in core.sys.posix.sys.wait)
520 //WIFSIGNALED (defined in core.sys.posix.sys.wait)
521 //WIFSTOPPED (defined in core.sys.posix.sys.wait)
522 //WSTOPSIG (defined in core.sys.posix.sys.wait)
523 //WTERMSIG (defined in core.sys.posix.sys.wait)
525 c_long a64l(const scope char*);
527 //char* ecvt(double, int, int *, int *); // LEGACY
528 double erand48(ref ushort[3]);
529 //char* fcvt(double, int, int *, int *); // LEGACY
530 //char* gcvt(double, int, char*); // LEGACY
531 int getsubopt(char**, const scope char**, char**);
533 char* initstate(uint, char*, size_t);
534 c_long jrand48(ref ushort[3]);
536 void lcong48(ref ushort[7]);
538 char* mktemp(char*); // LEGACY
540 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
542 c_long nrand48(ref ushort[3]);
543 int posix_openpt(int);
547 char* realpath(const scope char*, char*);
548 ushort *seed48(ref ushort[3]);
549 void setkey(const scope char*);
550 char* setstate(const scope char*);
551 void srand48(c_long);
555 else version (CRuntime_Bionic)
558 double erand48(ref ushort[3]);
559 //int grantpt(int); defined inline, but seems to do nothing in bionic
560 c_long jrand48(ref ushort[3]);
562 char* mktemp(char*); // LEGACY
564 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
566 c_long nrand48(ref ushort[3]);
568 int putenv(const scope char*);
569 c_long random() { return lrand48(); }
570 char* realpath(const scope char*, char*);
571 ushort* seed48(ref ushort[3]);
572 void srand48(c_long);
573 void srandom(uint s) { srand48(s); }
576 else version (CRuntime_Musl)
578 c_long a64l(const scope char*);
580 char* ecvt(double, int, int *, int *); // LEGACY
581 double erand48(ref ushort[3]);
582 char* fcvt(double, int, int *, int *); // LEGACY
583 char* gcvt(double, int, char*); // LEGACY
584 int getsubopt(char**, const scope char**, char**);
586 char* initstate(uint, char*, size_t);
587 c_long jrand48(ref ushort[3]);
589 void lcong48(ref ushort[7]);
591 char* mktemp(char*); // LEGACY
592 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
595 c_long nrand48(ref ushort[3]);
596 int posix_openpt(int);
600 char* realpath(const scope char*, char*);
601 ushort *seed48(ref ushort[3]);
602 void setkey(const scope char*);
603 char* setstate(const scope char*);
604 void srand48(c_long);
608 static if ( __USE_LARGEFILE64 )
610 int mkstemp64(char*);
611 alias mkstemp64 mkstemp;
619 else version (Solaris)
621 //WNOHANG (defined in core.sys.posix.sys.wait)
622 //WUNTRACED (defined in core.sys.posix.sys.wait)
623 //WEXITSTATUS (defined in core.sys.posix.sys.wait)
624 //WIFEXITED (defined in core.sys.posix.sys.wait)
625 //WIFSIGNALED (defined in core.sys.posix.sys.wait)
626 //WIFSTOPPED (defined in core.sys.posix.sys.wait)
627 //WSTOPSIG (defined in core.sys.posix.sys.wait)
628 //WTERMSIG (defined in core.sys.posix.sys.wait)
630 c_long a64l(const scope char*);
632 char* ecvt(double, int, int *, int *); // LEGACY
633 double erand48(ref ushort[3]);
634 char* fcvt(double, int, int *, int *); // LEGACY
635 char* gcvt(double, int, char*); // LEGACY
636 int getsubopt(char**, const scope char**, char**);
638 char* initstate(uint, char*, size_t);
639 c_long jrand48(ref ushort[3]);
641 void lcong48(ref ushort[7]);
643 char* mktemp(char*); // LEGACY
644 //int mkstemp(char*);
645 char* mkdtemp(char*); // Defined in IEEE 1003.1, 2008 Edition
647 c_long nrand48(ref ushort[3]);
648 int posix_openpt(int);
652 char* realpath(const scope char*, char*);
653 ushort *seed48(ref ushort[3]);
654 void setkey(const scope char*);
655 char* setstate(const scope char*);
656 void srand48(c_long);
664 static if ( __USE_LARGEFILE64 )
665 alias mkstemp mkstemp64;
669 int mkstemp64(char*);
671 static if ( __USE_LARGEFILE64 )
672 alias mkstemp64 mkstemp;
677 else version (CRuntime_UClibc)
679 c_long a64l(const scope char*);
681 char* ecvt(double, int, int *, int *);
682 double erand48(ref ushort[3]);
683 char* fcvt(double, int, int *, int *);
684 char* gcvt(double, int, char*);
685 int getsubopt(char**, const scope char**, char**);
687 char* initstate(uint, char*, size_t);
688 c_long jrand48(ref ushort[3]);
690 void lcong48(ref ushort[7]);
693 char* mkdtemp(char*);
695 c_long nrand48(ref ushort[3]);
696 int posix_openpt(int);
700 char* realpath(const scope char*, char*);
701 ushort* seed48(ref ushort[3]);
702 void setkey(const scope char*);
703 char* setstate(const scope char*);
704 void srand48(c_long);
708 static if ( __USE_LARGEFILE64 )
710 int mkstemp64(char*);
711 alias mkstemp64 mkstemp;