Correct feature names
[ACE_TAO.git] / ACE / ace / OS_NS_stdlib.h
blobab1e4f42a62ee228e0de6d46e19f380051d1aa85
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_NS_stdlib.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 * Originally in OS.h.
13 //=============================================================================
15 #ifndef ACE_OS_NS_STDLIB_H
16 # define ACE_OS_NS_STDLIB_H
18 # include /**/ "ace/pre.h"
20 # include "ace/config-all.h"
22 # if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 # endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/os_include/os_stdlib.h"
27 #include /**/ "ace/ACE_export.h"
29 #include "ace/Basic_Types.h" /* ACE_UINT64 and intptr_t in inl file */
31 #if defined (ACE_EXPORT_MACRO)
32 # undef ACE_EXPORT_MACRO
33 #endif
34 #define ACE_EXPORT_MACRO ACE_Export
36 // We need this for MVS... as well as Linux, etc...
37 // On Windows, we explicitly set this up as __cdecl so it's correct even
38 // if building with another calling convention, such as __stdcall.
39 #if defined (ACE_WIN32) && defined (_MSC_VER)
40 extern "C" {
41 typedef int (__cdecl *ACE_COMPARE_FUNC)(const void *, const void *);
43 #else
44 extern "C" {
45 typedef int (*ACE_COMPARE_FUNC)(const void *, const void *);
47 #endif /* ACE_WIN32 && _MSC_VER */
50 * We inline and undef some functions that may be implemented
51 * as macros on some platforms. This way macro definitions will
52 * be usable later as there is no way to save the macro definition
53 * using the pre-processor.
56 #if !defined (ACE_LACKS_STRTOLL) && !defined (ACE_STRTOLL_EQUIVALENT)
57 inline ACE_INT64 ace_strtoll_helper (const char *s, char **ptr, int base)
59 # if defined (strtoll)
60 return strtoll (s, ptr, base);
61 # undef strtoll
62 # else
63 return ACE_STD_NAMESPACE::strtoll (s, ptr, base);
64 # endif /* strtoll */
66 #endif /* !ACE_LACKS_STRTOLL && !ACE_STRTOLL_EQUIVALENT */
68 #if !defined (ACE_LACKS_STRTOULL) && !defined (ACE_STRTOULL_EQUIVALENT)
69 inline ACE_INT64 ace_strtoull_helper (const char *s, char **ptr, int base)
71 # if defined (strtoull)
72 return strtoull (s, ptr, base);
73 # undef strtoull
74 # else
75 return ACE_STD_NAMESPACE::strtoull (s, ptr, base);
76 # endif /* strtoull */
78 #endif /* !ACE_LACKS_STRTOULL && !ACE_STRTOULL_EQUIVALENT */
80 #if !defined (ACE_LACKS_RAND_R)
81 inline int ace_rand_r_helper (unsigned *seed)
83 # if defined (rand_r)
84 return rand_r (seed);
85 # undef rand_r
86 # else
87 return ACE_STD_NAMESPACE::rand_r (seed);
88 # endif /* rand_r */
90 #endif /* !ACE_LACKS_RAND_R */
92 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
94 namespace ACE_OS {
96 /** @name Non-standard functions
98 * These functions aren't in the standard.
101 //@{
102 ACE_NAMESPACE_INLINE_FUNCTION
103 void _exit (int status = 0) ACE_GCC_NO_RETURN;
105 ACE_NAMESPACE_INLINE_FUNCTION
106 void abort (void) ACE_GCC_NO_RETURN;
109 * Register an at exit hook. The @a name can be used to analyze shutdown
110 * problems
112 ACE_NAMESPACE_INLINE_FUNCTION
113 int atexit (ACE_EXIT_HOOK func, const char* name = 0);
116 * Convert string to integer
118 ACE_NAMESPACE_INLINE_FUNCTION
119 int atoi (const char *s);
121 # if defined (ACE_HAS_WCHAR)
123 * Convert string to integer
125 ACE_NAMESPACE_INLINE_FUNCTION
126 int atoi (const wchar_t *s);
127 # endif /* ACE_HAS_WCHAR */
130 * Convert string to long
132 ACE_NAMESPACE_INLINE_FUNCTION
133 long atol (const char *s);
136 * Convert string to long
138 # if defined (ACE_HAS_WCHAR)
139 ACE_NAMESPACE_INLINE_FUNCTION
140 long atol (const wchar_t *s);
141 # endif /* ACE_HAS_WCHAR */
144 * Convert string to double
146 ACE_NAMESPACE_INLINE_FUNCTION
147 double atof (const char *s);
150 * Convert string to double
152 # if defined (ACE_HAS_WCHAR)
153 ACE_NAMESPACE_INLINE_FUNCTION
154 double atof (const wchar_t *s);
155 # endif /* ACE_HAS_WCHAR */
157 // atop not in spec
159 * Convert string to pointer
161 ACE_NAMESPACE_INLINE_FUNCTION
162 void *atop (const char *s);
164 # if defined (ACE_HAS_WCHAR)
166 * Convert string to pointer
168 ACE_NAMESPACE_INLINE_FUNCTION
169 void *atop (const wchar_t *s);
170 # endif /* ACE_HAS_WCHAR */
172 ACE_NAMESPACE_INLINE_FUNCTION
173 void *bsearch (const void *key,
174 const void *base,
175 size_t nel,
176 size_t size,
177 ACE_COMPARE_FUNC);
179 extern ACE_Export
180 void *calloc (size_t elements, size_t sizeof_elements);
182 extern ACE_Export
183 void exit (int status = 0);
185 extern ACE_Export
186 void free (void *);
188 ACE_NAMESPACE_INLINE_FUNCTION
189 char *getenv (const char *symbol);
191 # if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32)
192 ACE_NAMESPACE_INLINE_FUNCTION
193 wchar_t *getenv (const wchar_t *symbol);
194 # endif /* ACE_HAS_WCHAR && ACE_WIN32 */
196 // not in spec
197 extern ACE_Export
198 ACE_TCHAR *getenvstrings (void);
200 // itoa not in spec
201 /// Converts an integer to a string.
202 ACE_NAMESPACE_INLINE_FUNCTION
203 char *itoa (int value, char *string, int radix);
205 #if defined (ACE_HAS_WCHAR)
206 /// Converts an integer to a string.
207 ACE_NAMESPACE_INLINE_FUNCTION
208 wchar_t *itoa (int value, wchar_t *string, int radix);
209 #endif /* ACE_HAS_WCHAR */
211 #if !defined (ACE_HAS_ITOA)
212 /// Emulated itoa - Converts an integer to a string.
213 extern ACE_Export
214 char *itoa_emulation (int value, char *string, int radix);
215 #endif /* !ACE_HAS_ITOA */
217 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW)
218 /// Emulated itow - Converts an integer to a string.
219 extern ACE_Export
220 wchar_t *itow_emulation (int value, wchar_t *string, int radix);
221 #endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */
223 extern ACE_Export
224 void *malloc (size_t);
226 ACE_NAMESPACE_INLINE_FUNCTION
227 ACE_HANDLE mkstemp (char *s);
229 # if defined (ACE_HAS_WCHAR)
230 ACE_NAMESPACE_INLINE_FUNCTION
231 ACE_HANDLE mkstemp (wchar_t *s);
232 # endif /* ACE_HAS_WCHAR */
234 #if defined (ACE_LACKS_MKSTEMP)
235 extern ACE_Export
236 ACE_HANDLE mkstemp_emulation (ACE_TCHAR * s);
237 #endif /* ACE_LACKS_MKSTEMP */
239 #if !defined (ACE_DISABLE_MKTEMP)
240 # if !defined (ACE_LACKS_MKTEMP)
241 ACE_NAMESPACE_INLINE_FUNCTION
242 char *mktemp (char *s);
244 # if defined (ACE_HAS_WCHAR)
245 ACE_NAMESPACE_INLINE_FUNCTION
246 wchar_t *mktemp (wchar_t *s);
247 # endif /* ACE_HAS_WCHAR */
248 # else
249 extern ACE_Export
250 ACE_TCHAR *mktemp (ACE_TCHAR *s);
251 # endif /* !ACE_LACKS_MKTEMP */
252 #endif /* !ACE_DISABLE_MKTEMP */
254 ACE_NAMESPACE_INLINE_FUNCTION
255 int putenv (const char *string);
257 #if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32)
258 // Windows is the only platform that supports a wchar_t environment.
259 // Since other platforms make @a string part of the environment, it's
260 // a certain memory leak to copy and transform wchar_t to char for
261 // emulating this, so it's not attempted.
262 ACE_NAMESPACE_INLINE_FUNCTION
263 int putenv (const wchar_t *string);
264 #endif /* ACE_HAS_WCHAR && ACE_WIN32 */
266 ACE_NAMESPACE_INLINE_FUNCTION
267 void qsort (void *base,
268 size_t nel,
269 size_t width,
270 ACE_COMPARE_FUNC);
272 ACE_NAMESPACE_INLINE_FUNCTION
273 int setenv(const char *envname, const char *envval, int overwrite);
275 ACE_NAMESPACE_INLINE_FUNCTION
276 int unsetenv(const char *name);
278 ACE_NAMESPACE_INLINE_FUNCTION
279 int rand (void);
281 ACE_NAMESPACE_INLINE_FUNCTION
282 int rand_r (unsigned int *seed);
284 extern ACE_Export
285 void *realloc (void *, size_t);
287 # if !defined (ACE_LACKS_REALPATH)
288 ACE_NAMESPACE_INLINE_FUNCTION
289 # else
290 extern ACE_Export
291 # endif /* !ACE_LACKS_REALPATH */
292 char *realpath (const char *file_name, char *resolved_name);
294 # if defined (ACE_HAS_WCHAR)
295 ACE_NAMESPACE_INLINE_FUNCTION
296 wchar_t *realpath (const wchar_t *file_name, wchar_t *resolved_name);
297 # endif /* ACE_HAS_WCHAR */
299 // exit_hook and set_exit_hook not in spec
300 /// Function that is called by <ACE_OS::exit>, if non-null.
301 extern ACE_Export ACE_EXIT_HOOK exit_hook_;
303 /// For use by ACE_Object_Manager only, to register its exit hook..
304 ACE_NAMESPACE_INLINE_FUNCTION
305 ACE_EXIT_HOOK set_exit_hook (ACE_EXIT_HOOK hook);
307 ACE_NAMESPACE_INLINE_FUNCTION
308 void srand (u_int seed);
310 // not in spec
311 extern ACE_Export
312 ACE_TCHAR *strenvdup (const ACE_TCHAR *str);
314 #if !defined (ACE_LACKS_STRTOD)
315 /// Converts a string to a double value (char version).
316 ACE_NAMESPACE_INLINE_FUNCTION
317 double strtod (const char *s, char **endptr);
318 #endif /* !ACE_LACKS_STRTOD */
320 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD)
321 /// Converts a string to a double value (wchar_t version).
322 ACE_NAMESPACE_INLINE_FUNCTION
323 double strtod (const wchar_t *s, wchar_t **endptr);
324 #endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */
326 /// Converts a string to a long value (char version).
327 ACE_NAMESPACE_INLINE_FUNCTION
328 long strtol (const char *s, char **ptr, int base);
330 #if defined (ACE_LACKS_STRTOL)
331 extern ACE_Export
332 long strtol_emulation (const char *nptr, char **endptr, int base);
333 #endif /* ACE_LACKS_STRTOL */
335 #if defined (ACE_HAS_WCHAR)
336 /// Converts a string to a long value (wchar_t version).
337 ACE_NAMESPACE_INLINE_FUNCTION
338 long strtol (const wchar_t *s, wchar_t **ptr, int base);
340 #if defined (ACE_LACKS_WCSTOL)
341 extern ACE_Export
342 long wcstol_emulation (const wchar_t *nptr, wchar_t **endptr, int base);
343 #endif /* ACE_LACKS_WCSTOL */
345 #endif /* ACE_HAS_WCHAR */
347 /// Converts a string to an unsigned long value (char version).
348 ACE_NAMESPACE_INLINE_FUNCTION
349 unsigned long strtoul (const char *s, char **ptr, int base);
351 #if defined (ACE_LACKS_STRTOUL)
352 extern ACE_Export
353 unsigned long strtoul_emulation (const char *nptr,
354 char **endptr,
355 int base);
356 #endif /* ACE_LACKS_STRTOUL */
358 #if defined (ACE_HAS_WCHAR)
359 /// Converts a string to an unsigned long value (wchar_t version).
360 ACE_NAMESPACE_INLINE_FUNCTION
361 unsigned long strtoul (const wchar_t *s, wchar_t **ptr, int base);
363 #if defined (ACE_LACKS_WCSTOUL)
364 extern ACE_Export
365 unsigned long wcstoul_emulation (const wchar_t *nptr,
366 wchar_t **endptr,
367 int base);
368 #endif /* ACE_LACKS_WCSTOUL */
370 #endif /* ACE_HAS_WCHAR */
372 /// Converts a string to a signed 64 bit int value (char version).
373 ACE_NAMESPACE_INLINE_FUNCTION
374 ACE_INT64 strtoll (const char *s, char **ptr, int base);
376 #if defined (ACE_LACKS_STRTOLL)
377 extern ACE_Export
378 ACE_INT64 strtoll_emulation (const char *nptr,
379 char **endptr,
380 int base);
381 #endif /* ACE_LACKS_STRTOLL */
383 #if defined (ACE_HAS_WCHAR)
384 /// Converts a string to a signed 64 bit int value (wchar_t version).
385 ACE_NAMESPACE_INLINE_FUNCTION
386 ACE_INT64 strtoll (const wchar_t *s, wchar_t **ptr, int base);
388 #if defined (ACE_LACKS_WCSTOLL)
389 extern ACE_Export
390 ACE_INT64 wcstoll_emulation (const wchar_t *nptr,
391 wchar_t **endptr,
392 int base);
393 #endif /* ACE_LACKS_WCSTOLL */
395 #endif /* ACE_HAS_WCHAR */
397 /// Converts a string to a unsigned 64 bit int value (char version).
398 ACE_NAMESPACE_INLINE_FUNCTION
399 ACE_UINT64 strtoull (const char *s, char **ptr, int base);
401 #if defined (ACE_LACKS_STRTOULL)
402 extern ACE_Export
403 ACE_UINT64 strtoull_emulation (const char *nptr,
404 char **endptr,
405 int base);
406 #endif /* ACE_LACKS_STRTOULL */
408 #if defined (ACE_HAS_WCHAR)
409 /// Converts a string to a unsigned 64 bit int value (wchar_t version).
410 ACE_NAMESPACE_INLINE_FUNCTION
411 ACE_UINT64 strtoull (const wchar_t *s, wchar_t **ptr, int base);
413 #if defined (ACE_LACKS_WCSTOULL)
414 extern ACE_Export
415 ACE_UINT64 wcstoull_emulation (const wchar_t *nptr,
416 wchar_t **endptr,
417 int base);
418 #endif /* ACE_LACKS_WCSTOULL */
420 #endif /* ACE_HAS_WCHAR */
422 ACE_NAMESPACE_INLINE_FUNCTION
423 int system (const ACE_TCHAR *s);
425 /// Get the name of the current program
427 /// Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.
428 ACE_NAMESPACE_INLINE_FUNCTION
429 const char *getprogname ();
431 #if !defined (ACE_HAS_GETPROGNAME)
432 extern ACE_Export
433 const char *getprogname_emulation ();
434 #endif /* !ACE_HAS_GETPROGNAME */
436 /// Set the name of the current program
438 /// Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.
439 ACE_NAMESPACE_INLINE_FUNCTION
440 void setprogname (const char* name);
442 #if !defined (ACE_HAS_SETPROGNAME)
443 extern ACE_Export
444 void setprogname_emulation (const char* name);
445 #endif /* !ACE_HAS_SETPROGNAME */
447 } /* namespace ACE_OS */
449 ACE_END_VERSIONED_NAMESPACE_DECL
451 # if defined (ACE_HAS_INLINED_OSCALLS)
452 # if defined (ACE_INLINE)
453 # undef ACE_INLINE
454 # endif /* ACE_INLINE */
455 # define ACE_INLINE inline
456 # include "ace/OS_NS_stdlib.inl"
457 # endif /* ACE_HAS_INLINED_OSCALLS */
459 # include /**/ "ace/post.h"
460 #endif /* ACE_OS_NS_STDLIB_H */