/src/core/sys/posix/stdlib.d
D | 316 lines | 142 code | 19 blank | 155 comment | 8 complexity | 28e5c67bb969b368fd9a6d16a14b463b MD5 | raw file
1/** 2 * D header file for POSIX. 3 * 4 * Copyright: Copyright Sean Kelly 2005 - 2009. 5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. 6 * Authors: Sean Kelly 7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 8 */ 9 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) 14 */ 15module core.sys.posix.stdlib; 16 17private import core.sys.posix.config; 18public import core.stdc.stdlib; 19public import core.sys.posix.sys.wait; 20 21version (Posix): 22extern (C): 23 24// 25// Required (defined in core.stdc.stdlib) 26// 27/* 28EXIT_FAILURE 29EXIT_SUCCESS 30NULL 31RAND_MAX 32MB_CUR_MAX 33div_t 34ldiv_t 35lldiv_t 36size_t 37wchar_t 38 39void _Exit(int); 40void abort(); 41int abs(int); 42int atexit(void function()); 43double atof(in char*); 44int atoi(in char*); 45c_long atol(in char*); 46long atoll(in char*); 47void* bsearch(in void*, in void*, size_t, size_t, int function(in void*, in void*)); 48void* calloc(size_t, size_t); 49div_t div(int, int); 50void exit(int); 51void free(void*); 52char* getenv(in char*); 53c_long labs(c_long); 54ldiv_t ldiv(c_long, c_long); 55long llabs(long); 56lldiv_t lldiv(long, long); 57void* malloc(size_t); 58int mblen(in char*, size_t); 59size_t mbstowcs(wchar_t*, in char*, size_t); 60int mbtowc(wchar_t*, in char*, size_t); 61void qsort(void*, size_t, size_t, int function(in void*, in void*)); 62int rand(); 63void* realloc(void*, size_t); 64void srand(uint); 65double strtod(in char*, char**); 66float strtof(in char*, char**); 67c_long strtol(in char*, char**, int); 68real strtold(in char*, char**); 69long strtoll(in char*, char**, int); 70c_ulong strtoul(in char*, char**, int); 71ulong strtoull(in char*, char**, int); 72int system(in char*); 73size_t wcstombs(char*, in wchar_t*, size_t); 74int wctomb(char*, wchar_t); 75*/ 76 77// 78// Advisory Information (ADV) 79// 80/* 81int posix_memalign(void**, size_t, size_t); 82*/ 83 84version( linux ) 85{ 86 int posix_memalign(void**, size_t, size_t); 87} 88else version( FreeBSD ) 89{ 90 int posix_memalign(void**, size_t, size_t); 91} 92 93// 94// C Extension (CX) 95// 96/* 97int setenv(in char*, in char*, int); 98int unsetenv(in char*); 99*/ 100 101version( linux ) 102{ 103 int setenv(in char*, in char*, int); 104 int unsetenv(in char*); 105 106 void* valloc(size_t); // LEGACY non-standard 107} 108else version( OSX ) 109{ 110 int setenv(in char*, in char*, int); 111 int unsetenv(in char*); 112 113 void* valloc(size_t); // LEGACY non-standard 114} 115else version( FreeBSD ) 116{ 117 int setenv(in char*, in char*, int); 118 int unsetenv(in char*); 119 120 void* valloc(size_t); // LEGACY non-standard 121} 122 123// 124// Thread-Safe Functions (TSF) 125// 126/* 127int rand_r(uint*); 128*/ 129 130version( linux ) 131{ 132 int rand_r(uint*); 133} 134else version( OSX ) 135{ 136 int rand_r(uint*); 137} 138else version( FreeBSD ) 139{ 140 int rand_r(uint*); 141} 142 143// 144// XOpen (XSI) 145// 146/* 147WNOHANG (defined in core.sys.posix.sys.wait) 148WUNTRACED (defined in core.sys.posix.sys.wait) 149WEXITSTATUS (defined in core.sys.posix.sys.wait) 150WIFEXITED (defined in core.sys.posix.sys.wait) 151WIFSIGNALED (defined in core.sys.posix.sys.wait) 152WIFSTOPPED (defined in core.sys.posix.sys.wait) 153WSTOPSIG (defined in core.sys.posix.sys.wait) 154WTERMSIG (defined in core.sys.posix.sys.wait) 155 156c_long a64l(in char*); 157double drand48(); 158char* ecvt(double, int, int *, int *); // LEGACY 159double erand48(ref ushort[3]); 160char* fcvt(double, int, int *, int *); // LEGACY 161char* gcvt(double, int, char*); // LEGACY 162// per spec: int getsubopt(char** char* const*, char**); 163int getsubopt(char**, in char**, char**); 164int grantpt(int); 165char* initstate(uint, char*, size_t); 166c_long jrand48(ref ushort[3]); 167char* l64a(c_long); 168void lcong48(ref ushort[7]); 169c_long lrand48(); 170char* mktemp(char*); // LEGACY 171int mkstemp(char*); 172c_long mrand48(); 173c_long nrand48(ref ushort[3]); 174int posix_openpt(int); 175char* ptsname(int); 176int putenv(char*); 177c_long random(); 178char* realpath(in char*, char*); 179ushort seed48(ref ushort[3]); 180void setkey(in char*); 181char* setstate(in char*); 182void srand48(c_long); 183void srandom(uint); 184int unlockpt(int); 185*/ 186 187version( linux ) 188{ 189 //WNOHANG (defined in core.sys.posix.sys.wait) 190 //WUNTRACED (defined in core.sys.posix.sys.wait) 191 //WEXITSTATUS (defined in core.sys.posix.sys.wait) 192 //WIFEXITED (defined in core.sys.posix.sys.wait) 193 //WIFSIGNALED (defined in core.sys.posix.sys.wait) 194 //WIFSTOPPED (defined in core.sys.posix.sys.wait) 195 //WSTOPSIG (defined in core.sys.posix.sys.wait) 196 //WTERMSIG (defined in core.sys.posix.sys.wait) 197 198 c_long a64l(in char*); 199 double drand48(); 200 char* ecvt(double, int, int *, int *); // LEGACY 201 double erand48(ref ushort[3]); 202 char* fcvt(double, int, int *, int *); // LEGACY 203 char* gcvt(double, int, char*); // LEGACY 204 int getsubopt(char**, in char**, char**); 205 int grantpt(int); 206 char* initstate(uint, char*, size_t); 207 c_long jrand48(ref ushort[3]); 208 char* l64a(c_long); 209 void lcong48(ref ushort[7]); 210 c_long lrand48(); 211 char* mktemp(char*); // LEGACY 212 //int mkstemp(char*); 213 c_long mrand48(); 214 c_long nrand48(ref ushort[3]); 215 int posix_openpt(int); 216 char* ptsname(int); 217 int putenv(char*); 218 c_long random(); 219 char* realpath(in char*, char*); 220 ushort seed48(ref ushort[3]); 221 void setkey(in char*); 222 char* setstate(in char*); 223 void srand48(c_long); 224 void srandom(uint); 225 int unlockpt(int); 226 227 static if( __USE_LARGEFILE64 ) 228 { 229 int mkstemp64(char*); 230 alias mkstemp64 mkstemp; 231 } 232 else 233 { 234 int mkstemp(char*); 235 } 236} 237else version( OSX ) 238{ 239 //WNOHANG (defined in core.sys.posix.sys.wait) 240 //WUNTRACED (defined in core.sys.posix.sys.wait) 241 //WEXITSTATUS (defined in core.sys.posix.sys.wait) 242 //WIFEXITED (defined in core.sys.posix.sys.wait) 243 //WIFSIGNALED (defined in core.sys.posix.sys.wait) 244 //WIFSTOPPED (defined in core.sys.posix.sys.wait) 245 //WSTOPSIG (defined in core.sys.posix.sys.wait) 246 //WTERMSIG (defined in core.sys.posix.sys.wait) 247 248 c_long a64l(in char*); 249 double drand48(); 250 char* ecvt(double, int, int *, int *); // LEGACY 251 double erand48(ref ushort[3]); 252 char* fcvt(double, int, int *, int *); // LEGACY 253 char* gcvt(double, int, char*); // LEGACY 254 int getsubopt(char**, in char**, char**); 255 int grantpt(int); 256 char* initstate(uint, char*, size_t); 257 c_long jrand48(ref ushort[3]); 258 char* l64a(c_long); 259 void lcong48(ref ushort[7]); 260 c_long lrand48(); 261 char* mktemp(char*); // LEGACY 262 int mkstemp(char*); 263 c_long mrand48(); 264 c_long nrand48(ref ushort[3]); 265 int posix_openpt(int); 266 char* ptsname(int); 267 int putenv(char*); 268 c_long random(); 269 char* realpath(in char*, char*); 270 ushort seed48(ref ushort[3]); 271 void setkey(in char*); 272 char* setstate(in char*); 273 void srand48(c_long); 274 void srandom(uint); 275 int unlockpt(int); 276} 277else version( FreeBSD ) 278{ 279 //WNOHANG (defined in core.sys.posix.sys.wait) 280 //WUNTRACED (defined in core.sys.posix.sys.wait) 281 //WEXITSTATUS (defined in core.sys.posix.sys.wait) 282 //WIFEXITED (defined in core.sys.posix.sys.wait) 283 //WIFSIGNALED (defined in core.sys.posix.sys.wait) 284 //WIFSTOPPED (defined in core.sys.posix.sys.wait) 285 //WSTOPSIG (defined in core.sys.posix.sys.wait) 286 //WTERMSIG (defined in core.sys.posix.sys.wait) 287 288 c_long a64l(in char*); 289 double drand48(); 290 //char* ecvt(double, int, int *, int *); // LEGACY 291 double erand48(ref ushort[3]); 292 //char* fcvt(double, int, int *, int *); // LEGACY 293 //char* gcvt(double, int, char*); // LEGACY 294 int getsubopt(char**, in char**, char**); 295 int grantpt(int); 296 char* initstate(uint, char*, size_t); 297 c_long jrand48(ref ushort[3]); 298 char* l64a(c_long); 299 void lcong48(ref ushort[7]); 300 c_long lrand48(); 301 char* mktemp(char*); // LEGACY 302 int mkstemp(char*); 303 c_long mrand48(); 304 c_long nrand48(ref ushort[3]); 305 int posix_openpt(int); 306 char* ptsname(int); 307 int putenv(char*); 308 c_long random(); 309 char* realpath(in char*, char*); 310 ushort seed48(ref ushort[3]); 311 void setkey(in char*); 312 char* setstate(in char*); 313 void srand48(c_long); 314 void srandom(uint); 315 int unlockpt(int); 316}