/oregoncore/dep/acelite/ace/OS_NS_stdlib.h

https://github.com/sysmaniax/k17oregoncoredb · C Header · 453 lines · 276 code · 88 blank · 89 comment · 21 complexity · c902f74001b0560cb3c3e683d1533c79 MD5 · raw file

  1. // -*- C++ -*-
  2. //=============================================================================
  3. /**
  4. * @file OS_NS_stdlib.h
  5. *
  6. * $Id: OS_NS_stdlib.h 88493 2010-01-12 19:17:42Z olli $
  7. *
  8. * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
  9. * @author Jesper S. M|ller<stophph@diku.dk>
  10. * @author and a cast of thousands...
  11. *
  12. * Originally in OS.h.
  13. */
  14. //=============================================================================
  15. #ifndef ACE_OS_NS_STDLIB_H
  16. # define ACE_OS_NS_STDLIB_H
  17. # include /**/ "ace/pre.h"
  18. # include "ace/config-all.h"
  19. # if !defined (ACE_LACKS_PRAGMA_ONCE)
  20. # pragma once
  21. # endif /* ACE_LACKS_PRAGMA_ONCE */
  22. #include "ace/os_include/os_stdlib.h"
  23. #include /**/ "ace/ACE_export.h"
  24. #include "ace/Basic_Types.h" /* ACE_UINT64 and intptr_t in inl file */
  25. #if defined (ACE_EXPORT_MACRO)
  26. # undef ACE_EXPORT_MACRO
  27. #endif
  28. #define ACE_EXPORT_MACRO ACE_Export
  29. // We need this for MVS... as well as Linux, etc...
  30. // On Windows, we explicitly set this up as __cdecl so it's correct even
  31. // if building with another calling convention, such as __stdcall.
  32. #if defined (ACE_WIN32) && defined (_MSC_VER)
  33. extern "C" {
  34. typedef int (__cdecl *ACE_COMPARE_FUNC)(const void *, const void *);
  35. }
  36. #else
  37. extern "C" {
  38. typedef int (*ACE_COMPARE_FUNC)(const void *, const void *);
  39. }
  40. #endif /* ACE_WIN32 && _MSC_VER */
  41. // FreeBSD has atop macro (not related to ACE_OS::atop)
  42. #if defined (atop)
  43. # undef atop
  44. #endif
  45. /*
  46. * We inline and undef some functions that may be implemented
  47. * as macros on some platforms. This way macro definitions will
  48. * be usable later as there is no way to save the macro definition
  49. * using the pre-processor.
  50. */
  51. #if !defined (ACE_LACKS_STRTOLL) && !defined (ACE_STRTOLL_EQUIVALENT)
  52. inline ACE_INT64 ace_strtoll_helper (const char *s, char **ptr, int base)
  53. {
  54. # if defined (strtoll)
  55. return strtoll (s, ptr, base);
  56. # undef strtoll
  57. # else
  58. return ACE_STD_NAMESPACE::strtoll (s, ptr, base);
  59. # endif /* strtoll */
  60. }
  61. #endif /* !ACE_LACKS_STRTOLL && !ACE_STRTOLL_EQUIVALENT */
  62. #if !defined (ACE_LACKS_STRTOULL) && !defined (ACE_STRTOULL_EQUIVALENT)
  63. inline ACE_INT64 ace_strtoull_helper (const char *s, char **ptr, int base)
  64. {
  65. # if defined (strtoull)
  66. return strtoull (s, ptr, base);
  67. # undef strtoull
  68. # else
  69. return ACE_STD_NAMESPACE::strtoull (s, ptr, base);
  70. # endif /* strtoull */
  71. }
  72. #endif /* !ACE_LACKS_STRTOULL && !ACE_STRTOULL_EQUIVALENT */
  73. ACE_BEGIN_VERSIONED_NAMESPACE_DECL
  74. namespace ACE_OS {
  75. /** @name Non-standard functions
  76. *
  77. * These functions aren't in the standard.
  78. *
  79. */
  80. //@{
  81. ACE_NAMESPACE_INLINE_FUNCTION
  82. void _exit (int status = 0);
  83. ACE_NAMESPACE_INLINE_FUNCTION
  84. void abort (void);
  85. /**
  86. * Register an at exit hook. The @a name can be used to analyze shutdown
  87. * problems
  88. */
  89. ACE_NAMESPACE_INLINE_FUNCTION
  90. int atexit (ACE_EXIT_HOOK func, const char* name = 0);
  91. /*
  92. * Convert string to integer
  93. */
  94. ACE_NAMESPACE_INLINE_FUNCTION
  95. int atoi (const char *s);
  96. # if defined (ACE_HAS_WCHAR)
  97. /*
  98. * Convert string to integer
  99. */
  100. ACE_NAMESPACE_INLINE_FUNCTION
  101. int atoi (const wchar_t *s);
  102. # endif /* ACE_HAS_WCHAR */
  103. /*
  104. * Convert string to long
  105. */
  106. ACE_NAMESPACE_INLINE_FUNCTION
  107. long atol (const char *s);
  108. /*
  109. * Convert string to long
  110. */
  111. # if defined (ACE_HAS_WCHAR)
  112. ACE_NAMESPACE_INLINE_FUNCTION
  113. long atol (const wchar_t *s);
  114. # endif /* ACE_HAS_WCHAR */
  115. /*
  116. * Convert string to double
  117. */
  118. ACE_NAMESPACE_INLINE_FUNCTION
  119. double atof (const char *s);
  120. /*
  121. * Convert string to double
  122. */
  123. # if defined (ACE_HAS_WCHAR)
  124. ACE_NAMESPACE_INLINE_FUNCTION
  125. double atof (const wchar_t *s);
  126. # endif /* ACE_HAS_WCHAR */
  127. // atop not in spec
  128. /*
  129. * Convert string to pointer
  130. */
  131. ACE_NAMESPACE_INLINE_FUNCTION
  132. void *atop (const char *s);
  133. # if defined (ACE_HAS_WCHAR)
  134. /*
  135. * Convert string to pointer
  136. */
  137. ACE_NAMESPACE_INLINE_FUNCTION
  138. void *atop (const wchar_t *s);
  139. # endif /* ACE_HAS_WCHAR */
  140. ACE_NAMESPACE_INLINE_FUNCTION
  141. void *bsearch (const void *key,
  142. const void *base,
  143. size_t nel,
  144. size_t size,
  145. ACE_COMPARE_FUNC);
  146. extern ACE_Export
  147. void *calloc (size_t elements, size_t sizeof_elements);
  148. extern ACE_Export
  149. void exit (int status = 0);
  150. extern ACE_Export
  151. void free (void *);
  152. ACE_NAMESPACE_INLINE_FUNCTION
  153. char *getenv (const char *symbol);
  154. # if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32)
  155. ACE_NAMESPACE_INLINE_FUNCTION
  156. wchar_t *getenv (const wchar_t *symbol);
  157. # endif /* ACE_HAS_WCHAR && ACE_WIN32 */
  158. // not in spec
  159. extern ACE_Export
  160. ACE_TCHAR *getenvstrings (void);
  161. // itoa not in spec
  162. /// Converts an integer to a string.
  163. ACE_NAMESPACE_INLINE_FUNCTION
  164. char *itoa (int value, char *string, int radix);
  165. #if defined (ACE_HAS_WCHAR)
  166. /// Converts an integer to a string.
  167. ACE_NAMESPACE_INLINE_FUNCTION
  168. wchar_t *itoa (int value, wchar_t *string, int radix);
  169. #endif /* ACE_HAS_WCHAR */
  170. #if !defined (ACE_HAS_ITOA)
  171. /// Emulated itoa - Converts an integer to a string.
  172. extern ACE_Export
  173. char *itoa_emulation (int value, char *string, int radix);
  174. #endif /* !ACE_HAS_ITOA */
  175. #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW)
  176. /// Emulated itow - Converts an integer to a string.
  177. extern ACE_Export
  178. wchar_t *itow_emulation (int value, wchar_t *string, int radix);
  179. #endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */
  180. extern ACE_Export
  181. void *malloc (size_t);
  182. ACE_NAMESPACE_INLINE_FUNCTION
  183. ACE_HANDLE mkstemp (char *s);
  184. # if defined (ACE_HAS_WCHAR)
  185. ACE_NAMESPACE_INLINE_FUNCTION
  186. ACE_HANDLE mkstemp (wchar_t *s);
  187. # endif /* ACE_HAS_WCHAR */
  188. #if defined (ACE_LACKS_MKSTEMP)
  189. extern ACE_Export
  190. ACE_HANDLE mkstemp_emulation (ACE_TCHAR * s);
  191. #endif /* ACE_LACKS_MKSTEMP */
  192. #if !defined (ACE_LACKS_MKTEMP)
  193. ACE_NAMESPACE_INLINE_FUNCTION
  194. char *mktemp (char *s);
  195. # if defined (ACE_HAS_WCHAR)
  196. ACE_NAMESPACE_INLINE_FUNCTION
  197. wchar_t *mktemp (wchar_t *s);
  198. # endif /* ACE_HAS_WCHAR */
  199. #else
  200. extern ACE_Export
  201. ACE_TCHAR *mktemp (ACE_TCHAR *s);
  202. #endif /* !ACE_LACKS_MKTEMP */
  203. ACE_NAMESPACE_INLINE_FUNCTION
  204. int putenv (const char *string);
  205. #if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32)
  206. // Windows is the only platform that supports a wchar_t environment.
  207. // Since other platforms make @a string part of the environment, it's
  208. // a certain memory leak to copy and transform wchar_t to char for
  209. // emulating this, so it's not attempted.
  210. ACE_NAMESPACE_INLINE_FUNCTION
  211. int putenv (const wchar_t *string);
  212. #endif /* ACE_HAS_WCHAR && ACE_WIN32 */
  213. ACE_NAMESPACE_INLINE_FUNCTION
  214. void qsort (void *base,
  215. size_t nel,
  216. size_t width,
  217. ACE_COMPARE_FUNC);
  218. ACE_NAMESPACE_INLINE_FUNCTION
  219. int setenv(const char *envname, const char *envval, int overwrite);
  220. ACE_NAMESPACE_INLINE_FUNCTION
  221. int unsetenv(const char *name);
  222. ACE_NAMESPACE_INLINE_FUNCTION
  223. int rand (void);
  224. ACE_NAMESPACE_INLINE_FUNCTION
  225. int rand_r (ACE_RANDR_TYPE &seed);
  226. extern ACE_Export
  227. void *realloc (void *, size_t);
  228. # if !defined (ACE_LACKS_REALPATH)
  229. ACE_NAMESPACE_INLINE_FUNCTION
  230. # else
  231. extern ACE_Export
  232. # endif /* !ACE_LACKS_REALPATH */
  233. char *realpath (const char *file_name, char *resolved_name);
  234. # if defined (ACE_HAS_WCHAR)
  235. ACE_NAMESPACE_INLINE_FUNCTION
  236. wchar_t *realpath (const wchar_t *file_name, wchar_t *resolved_name);
  237. # endif /* ACE_HAS_WCHAR */
  238. // exit_hook and set_exit_hook not in spec
  239. /// Function that is called by <ACE_OS::exit>, if non-null.
  240. extern ACE_Export ACE_EXIT_HOOK exit_hook_;
  241. /// For use by ACE_Object_Manager only, to register its exit hook..
  242. ACE_NAMESPACE_INLINE_FUNCTION
  243. ACE_EXIT_HOOK set_exit_hook (ACE_EXIT_HOOK hook);
  244. ACE_NAMESPACE_INLINE_FUNCTION
  245. void srand (u_int seed);
  246. // not in spec
  247. extern ACE_Export
  248. ACE_TCHAR *strenvdup (const ACE_TCHAR *str);
  249. #if !defined (ACE_LACKS_STRTOD)
  250. /// Converts a string to a double value (char version).
  251. ACE_NAMESPACE_INLINE_FUNCTION
  252. double strtod (const char *s, char **endptr);
  253. #endif /* !ACE_LACKS_STRTOD */
  254. #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD)
  255. /// Converts a string to a double value (wchar_t version).
  256. ACE_NAMESPACE_INLINE_FUNCTION
  257. double strtod (const wchar_t *s, wchar_t **endptr);
  258. #endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */
  259. /// Converts a string to a long value (char version).
  260. ACE_NAMESPACE_INLINE_FUNCTION
  261. long strtol (const char *s, char **ptr, int base);
  262. #if defined (ACE_LACKS_STRTOL)
  263. extern ACE_Export
  264. long strtol_emulation (const char *nptr, char **endptr, int base);
  265. #endif /* ACE_LACKS_STRTOL */
  266. #if defined (ACE_HAS_WCHAR)
  267. /// Converts a string to a long value (wchar_t version).
  268. ACE_NAMESPACE_INLINE_FUNCTION
  269. long strtol (const wchar_t *s, wchar_t **ptr, int base);
  270. #if defined (ACE_LACKS_WCSTOL)
  271. extern ACE_Export
  272. long wcstol_emulation (const wchar_t *nptr, wchar_t **endptr, int base);
  273. #endif /* ACE_LACKS_WCSTOL */
  274. #endif /* ACE_HAS_WCHAR */
  275. /// Converts a string to an unsigned long value (char version).
  276. ACE_NAMESPACE_INLINE_FUNCTION
  277. unsigned long strtoul (const char *s, char **ptr, int base);
  278. #if defined (ACE_LACKS_STRTOUL)
  279. extern ACE_Export
  280. unsigned long strtoul_emulation (const char *nptr,
  281. char **endptr,
  282. int base);
  283. #endif /* ACE_LACKS_STRTOUL */
  284. #if defined (ACE_HAS_WCHAR)
  285. /// Converts a string to an unsigned long value (wchar_t version).
  286. ACE_NAMESPACE_INLINE_FUNCTION
  287. unsigned long strtoul (const wchar_t *s, wchar_t **ptr, int base);
  288. #if defined (ACE_LACKS_WCSTOUL)
  289. extern ACE_Export
  290. unsigned long wcstoul_emulation (const wchar_t *nptr,
  291. wchar_t **endptr,
  292. int base);
  293. #endif /* ACE_LACKS_WCSTOUL */
  294. #endif /* ACE_HAS_WCHAR */
  295. /// Converts a string to a signed 64 bit int value (char version).
  296. ACE_NAMESPACE_INLINE_FUNCTION
  297. ACE_INT64 strtoll (const char *s, char **ptr, int base);
  298. #if defined (ACE_LACKS_STRTOLL)
  299. extern ACE_Export
  300. ACE_INT64 strtoll_emulation (const char *nptr,
  301. char **endptr,
  302. int base);
  303. #endif /* ACE_LACKS_STRTOLL */
  304. #if defined (ACE_HAS_WCHAR)
  305. /// Converts a string to a signed 64 bit int value (wchar_t version).
  306. ACE_NAMESPACE_INLINE_FUNCTION
  307. ACE_INT64 strtoll (const wchar_t *s, wchar_t **ptr, int base);
  308. #if defined (ACE_LACKS_WCSTOLL)
  309. extern ACE_Export
  310. ACE_INT64 wcstoll_emulation (const wchar_t *nptr,
  311. wchar_t **endptr,
  312. int base);
  313. #endif /* ACE_LACKS_WCSTOLL */
  314. #endif /* ACE_HAS_WCHAR */
  315. /// Converts a string to a unsigned 64 bit int value (char version).
  316. ACE_NAMESPACE_INLINE_FUNCTION
  317. ACE_UINT64 strtoull (const char *s, char **ptr, int base);
  318. #if defined (ACE_LACKS_STRTOULL)
  319. extern ACE_Export
  320. ACE_UINT64 strtoull_emulation (const char *nptr,
  321. char **endptr,
  322. int base);
  323. #endif /* ACE_LACKS_STRTOULL */
  324. #if defined (ACE_HAS_WCHAR)
  325. /// Converts a string to a unsigned 64 bit int value (wchar_t version).
  326. ACE_NAMESPACE_INLINE_FUNCTION
  327. ACE_UINT64 strtoull (const wchar_t *s, wchar_t **ptr, int base);
  328. #if defined (ACE_LACKS_WCSTOULL)
  329. extern ACE_Export
  330. ACE_UINT64 wcstoull_emulation (const wchar_t *nptr,
  331. wchar_t **endptr,
  332. int base);
  333. #endif /* ACE_LACKS_WCSTOULL */
  334. #endif /* ACE_HAS_WCHAR */
  335. ACE_NAMESPACE_INLINE_FUNCTION
  336. int system (const ACE_TCHAR *s);
  337. /// Get the name of the current program
  338. ///
  339. /// Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.
  340. ACE_NAMESPACE_INLINE_FUNCTION
  341. const char *getprogname ();
  342. #if !defined (ACE_HAS_GETPROGNAME)
  343. extern ACE_Export
  344. const char *getprogname_emulation ();
  345. #endif /* !ACE_HAS_GETPROGNAME */
  346. /// Set the name of the current program
  347. ///
  348. /// Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.
  349. ACE_NAMESPACE_INLINE_FUNCTION
  350. void setprogname (const char* name);
  351. #if !defined (ACE_HAS_SETPROGNAME)
  352. extern ACE_Export
  353. void setprogname_emulation (const char* name);
  354. #endif /* !ACE_HAS_SETPROGNAME */
  355. } /* namespace ACE_OS */
  356. ACE_END_VERSIONED_NAMESPACE_DECL
  357. # if defined (ACE_HAS_INLINED_OSCALLS)
  358. # if defined (ACE_INLINE)
  359. # undef ACE_INLINE
  360. # endif /* ACE_INLINE */
  361. # define ACE_INLINE inline
  362. # include "ace/OS_NS_stdlib.inl"
  363. # endif /* ACE_HAS_INLINED_OSCALLS */
  364. # include /**/ "ace/post.h"
  365. #endif /* ACE_OS_NS_STDLIB_H */