/src/core/sys/posix/stdlib.d

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