3 //=============================================================================
7 * $Id: OS_NS_stdlib.h 81804 2008-05-29 16:12:07Z vzykov $
9 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
10 * @author Jesper S. M|ller<stophph@diku.dk>
11 * @author and a cast of thousands...
15 //=============================================================================
17 #ifndef ACE_OS_NS_STDLIB_H
18 # define ACE_OS_NS_STDLIB_H
20 # include /**/ "ace/pre.h"
22 # include "ace/config-all.h"
24 # if !defined (ACE_LACKS_PRAGMA_ONCE)
26 # endif /* ACE_LACKS_PRAGMA_ONCE */
28 #include "ace/os_include/os_stdlib.h"
29 #include /**/ "ace/ACE_export.h"
31 #include "ace/Basic_Types.h" /* ACE_UINT64 and intptr_t in inl file */
33 #if defined (ACE_EXPORT_MACRO)
34 # undef ACE_EXPORT_MACRO
36 #define ACE_EXPORT_MACRO ACE_Export
38 # if defined (ACE_HAS_BROKEN_R_ROUTINES)
40 # endif /* ACE_HAS_BROKEN_R_ROUTINES */
42 // We need this for MVS... as well as Linux, etc...
43 // On Windows, we explicitly set this up as __cdecl so it's correct even
44 // if building with another calling convention, such as __stdcall.
45 #if defined (ACE_WIN32) && defined (_MSC_VER)
47 typedef int (__cdecl
*ACE_COMPARE_FUNC
)(const void *, const void *);
51 typedef int (*ACE_COMPARE_FUNC
)(const void *, const void *);
53 #endif /* ACE_WIN32 && _MSC_VER */
55 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
59 /** @name Non-standard functions
61 * These functions aren't in the standard.
67 ACE_NAMESPACE_INLINE_FUNCTION
68 void _exit (int status
= 0);
70 ACE_NAMESPACE_INLINE_FUNCTION
73 ACE_NAMESPACE_INLINE_FUNCTION
74 int atexit (ACE_EXIT_HOOK func
);
76 ACE_NAMESPACE_INLINE_FUNCTION
77 int atoi (const char *s
);
79 # if defined (ACE_HAS_WCHAR)
80 ACE_NAMESPACE_INLINE_FUNCTION
81 int atoi (const wchar_t *s
);
82 # endif /* ACE_HAS_WCHAR */
89 ACE_NAMESPACE_INLINE_FUNCTION
90 void *atop (const char *s
);
92 # if defined (ACE_HAS_WCHAR)
93 ACE_NAMESPACE_INLINE_FUNCTION
94 void *atop (const wchar_t *s
);
95 # endif /* ACE_HAS_WCHAR */
97 ACE_NAMESPACE_INLINE_FUNCTION
98 void *bsearch (const void *key
,
105 void *calloc (size_t elements
, size_t sizeof_elements
);
108 void exit (int status
= 0);
113 ACE_NAMESPACE_INLINE_FUNCTION
114 char *getenv (const char *symbol
);
116 # if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32)
117 ACE_NAMESPACE_INLINE_FUNCTION
118 wchar_t *getenv (const wchar_t *symbol
);
119 # endif /* ACE_HAS_WCHAR && ACE_WIN32 */
123 ACE_TCHAR
*getenvstrings (void);
126 /// Converts an integer to a string.
127 ACE_NAMESPACE_INLINE_FUNCTION
128 char *itoa (int value
, char *string
, int radix
);
130 #if defined (ACE_HAS_WCHAR)
131 /// Converts an integer to a string.
132 ACE_NAMESPACE_INLINE_FUNCTION
133 wchar_t *itoa (int value
, wchar_t *string
, int radix
);
134 #endif /* ACE_HAS_WCHAR */
136 #if !defined (ACE_HAS_ITOA)
137 /// Emulated itoa - Converts an integer to a string.
139 char *itoa_emulation (int value
, char *string
, int radix
);
140 #endif /* !ACE_HAS_ITOA */
142 #if defined (ACE_HAS_WCHAR) && defined (ACE_LACKS_ITOW)
143 /// Emulated itow - Converts an integer to a string.
145 wchar_t *itow_emulation (int value
, wchar_t *string
, int radix
);
146 #endif /* ACE_HAS_WCHAR && ACE_LACKS_ITOW */
149 void *malloc (size_t);
151 ACE_NAMESPACE_INLINE_FUNCTION
152 ACE_HANDLE
mkstemp (char *s
);
154 # if defined (ACE_HAS_WCHAR)
155 ACE_NAMESPACE_INLINE_FUNCTION
156 ACE_HANDLE
mkstemp (wchar_t *s
);
157 # endif /* ACE_HAS_WCHAR */
159 #if defined (ACE_LACKS_MKSTEMP)
161 ACE_HANDLE
mkstemp_emulation (ACE_TCHAR
* s
);
162 #endif /* ACE_LACKS_MKSTEMP */
164 #if !defined (ACE_LACKS_MKTEMP)
165 ACE_NAMESPACE_INLINE_FUNCTION
166 char *mktemp (char *s
);
168 # if defined (ACE_HAS_WCHAR)
169 ACE_NAMESPACE_INLINE_FUNCTION
170 wchar_t *mktemp (wchar_t *s
);
171 # endif /* ACE_HAS_WCHAR */
174 ACE_TCHAR
*mktemp (ACE_TCHAR
*s
);
175 #endif /* !ACE_LACKS_MSTEMP */
177 ACE_NAMESPACE_INLINE_FUNCTION
178 int putenv (const char *string
);
180 #if defined (ACE_HAS_WCHAR) && defined (ACE_WIN32)
181 // Windows is the only platform that supports a wchar_t environment.
182 // Since other platforms make @a string part of the environment, it's
183 // a certain memory leak to copy and transform wchar_t to char for
184 // emulating this, so it's not attempted.
185 ACE_NAMESPACE_INLINE_FUNCTION
186 int putenv (const wchar_t *string
);
187 #endif /* ACE_HAS_WCHAR && ACE_WIN32 */
189 ACE_NAMESPACE_INLINE_FUNCTION
190 void qsort (void *base
,
195 ACE_NAMESPACE_INLINE_FUNCTION
198 ACE_NAMESPACE_INLINE_FUNCTION
199 int rand_r (ACE_RANDR_TYPE
&seed
);
202 void *realloc (void *, size_t);
204 #if !defined (ACE_HAS_WINCE)
205 # if !defined (ACE_LACKS_REALPATH)
206 ACE_NAMESPACE_INLINE_FUNCTION
209 # endif /* !ACE_LACKS_REALPATH */
210 char *realpath (const char *file_name
, char *resolved_name
);
212 # if defined (ACE_HAS_WCHAR)
213 ACE_NAMESPACE_INLINE_FUNCTION
214 wchar_t *realpath (const wchar_t *file_name
, wchar_t *resolved_name
);
215 # endif /* ACE_HAS_WCHAR */
216 #endif /* ACE_HAS_WINCE */
218 // exit_hook and set_exit_hook not in spec
219 /// Function that is called by <ACE_OS::exit>, if non-null.
220 extern ACE_Export ACE_EXIT_HOOK exit_hook_
;
222 /// For use by ACE_Object_Manager only, to register its exit hook..
223 ACE_NAMESPACE_INLINE_FUNCTION
224 ACE_EXIT_HOOK
set_exit_hook (ACE_EXIT_HOOK hook
);
226 ACE_NAMESPACE_INLINE_FUNCTION
227 void srand (u_int seed
);
231 ACE_TCHAR
*strenvdup (const ACE_TCHAR
*str
);
233 #if !defined (ACE_LACKS_STRTOD)
234 /// Converts a string to a double value (char version).
235 ACE_NAMESPACE_INLINE_FUNCTION
236 double strtod (const char *s
, char **endptr
);
237 #endif /* !ACE_LACKS_STRTOD */
239 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOD)
240 /// Converts a string to a double value (wchar_t version).
241 ACE_NAMESPACE_INLINE_FUNCTION
242 double strtod (const wchar_t *s
, wchar_t **endptr
);
243 #endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOD */
245 /// Converts a string to a long value (char version).
246 ACE_NAMESPACE_INLINE_FUNCTION
247 long strtol (const char *s
, char **ptr
, int base
);
249 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOL)
250 /// Converts a string to a long value (wchar_t version).
251 ACE_NAMESPACE_INLINE_FUNCTION
252 long strtol (const wchar_t *s
, wchar_t **ptr
, int base
);
253 #endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOL */
255 #if defined (ACE_LACKS_STRTOL)
257 long strtol_emulation (const char *nptr
, char **endptr
, int base
);
258 #endif /* ACE_LACKS_STRTOL */
260 /// Converts a string to an unsigned long value (char version).
261 ACE_NAMESPACE_INLINE_FUNCTION
262 unsigned long strtoul (const char *s
, char **ptr
, int base
);
264 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOUL)
265 /// Converts a string to an unsigned long value (wchar_t version).
266 ACE_NAMESPACE_INLINE_FUNCTION
267 unsigned long strtoul (const wchar_t *s
, wchar_t **ptr
, int base
);
268 #endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */
270 #if defined (ACE_LACKS_STRTOUL)
272 unsigned long strtoul_emulation (const char *nptr
,
275 #endif /* ACE_LACKS_STRTOUL */
277 /// Converts a string to a 64 bit int value (char version).
278 ACE_NAMESPACE_INLINE_FUNCTION
279 ACE_UINT64
strtoull (const char *s
, char **ptr
, int base
);
281 #if defined (ACE_HAS_WCHAR) && !defined (ACE_LACKS_WCSTOULL)
282 /// Converts a string to a 64 bit int value (wchar_t version).
283 ACE_NAMESPACE_INLINE_FUNCTION
284 ACE_UINT64
strtoull (const wchar_t *s
, wchar_t **ptr
, int base
);
285 #endif /* ACE_HAS_WCHAR && !ACE_LACKS_WCSTOUL */
287 #if defined (ACE_LACKS_STRTOULL)
289 ACE_UINT64
strtoull_emulation (const char *nptr
,
292 #endif /* ACE_LACKS_STRTOULL */
294 ACE_NAMESPACE_INLINE_FUNCTION
295 int system (const ACE_TCHAR
*s
);
297 /// Get the name of the current program
299 /// Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.
300 ACE_NAMESPACE_INLINE_FUNCTION
301 const char *getprogname ();
303 #if !defined (ACE_HAS_GETPROGNAME)
305 const char *getprogname_emulation ();
306 #endif /* !ACE_HAS_GETPROGNAME */
308 /// Set the name of the current program
310 /// Originally from NetBSD, now found in *BSD, Cygwin, Darwin, etc.
311 ACE_NAMESPACE_INLINE_FUNCTION
312 void setprogname (const char* name
);
314 #if !defined (ACE_HAS_SETPROGNAME)
316 void setprogname_emulation (const char* name
);
317 #endif /* !ACE_HAS_SETPROGNAME */
319 } /* namespace ACE_OS */
321 ACE_END_VERSIONED_NAMESPACE_DECL
323 # if defined (ACE_HAS_INLINED_OSCALLS)
324 # if defined (ACE_INLINE)
326 # endif /* ACE_INLINE */
327 # define ACE_INLINE inline
328 # include "ace/OS_NS_stdlib.inl"
329 # endif /* ACE_HAS_INLINED_OSCALLS */
331 # include /**/ "ace/post.h"
332 #endif /* ACE_OS_NS_STDLIB_H */