1 #ifndef CYGONCE_ISO_STDLIB_H
2 #define CYGONCE_ISO_STDLIB_H
3 /*========================================================================
7 // ISO standard library functions
9 //========================================================================
10 //####ECOSGPLCOPYRIGHTBEGIN####
11 // -------------------------------------------
12 // This file is part of eCos, the Embedded Configurable Operating System.
13 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
38 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39 // at http://sources.redhat.com/ecos/ecos-license/
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //========================================================================
43 //#####DESCRIPTIONBEGIN####
45 // Author(s): jlarmour
48 // Purpose: This file provides the stdlib functions required by
49 // ISO C and POSIX 1003.1.
50 // Description: The real contents of this file get set from the
51 // configuration (set by the implementation)
52 // Usage: #include <stdlib.h>
54 //####DESCRIPTIONEND####
56 //======================================================================
61 #include <pkgconf/isoinfra.h> /* Configuration header */
65 /* This is the "standard" way to get NULL, wchar_t and size_t from stddef.h,
66 * which is the canonical location of the definitions.
70 #define __need_wchar_t
73 #include <cyg/infra/cyg_type.h> /* For CYGBLD_ATTRIB_NORET etc. */
75 /*==========================================================================*/
77 #if CYGINT_ISO_STDLIB_STRCONV
78 # ifdef CYGBLD_ISO_STDLIB_STRCONV_HEADER
79 # include CYGBLD_ISO_STDLIB_STRCONV_HEADER
82 /* ISO C 7.10.1 - String conversion functions */
89 atoi( const char * /* int_str */ );
92 atol( const char * /* long_str */ );
95 strtol( const char * /* long_str */, char ** /* endptr */,
99 strtoul( const char * /* ulong_str */, char ** /* endptr */,
110 /*==========================================================================*/
112 #if CYGINT_ISO_STDLIB_STRCONV_FLOAT
113 # ifdef CYGBLD_ISO_STDLIB_STRCONV_FLOAT_HEADER
114 # include CYGBLD_ISO_STDLIB_STRCONV_FLOAT_HEADER
117 /* ISO C 7.10.1 - String conversion functions */
124 atof( const char * /* double_str */ );
127 strtod( const char * /* double_str */, char ** /* endptr */ );
137 /*==========================================================================*/
140 # ifdef CYGBLD_ISO_RAND_HEADER
141 # include CYGBLD_ISO_RAND_HEADER
144 /* ISO C 7.10.2 - Pseudo-random sequence generation functions */
146 /* Maximum value returned by rand(). */
147 #define RAND_MAX 2147483647
157 srand( unsigned int /* seed */ );
159 /* POSIX 1003.1 section 8.3.8 rand_r() */
161 rand_r( unsigned int * /* seed */ );
170 /*==========================================================================*/
172 #if CYGINT_ISO_MALLOC
173 # ifdef CYGBLD_ISO_MALLOC_HEADER
174 # include CYGBLD_ISO_MALLOC_HEADER
177 /* ISO C 7.10.3 - Memory management functions */
184 calloc( size_t /* num_objects */, size_t /* object_size */ );
187 free( void * /* ptr */ );
190 malloc( size_t /* size */ );
193 realloc( void * /* ptr */, size_t /* size */ );
202 /*==========================================================================*/
204 #if CYGINT_ISO_MALLINFO
205 # ifdef CYGBLD_ISO_MALLINFO_HEADER
206 # include CYGBLD_ISO_MALLINFO_HEADER
213 /* SVID2/XPG mallinfo structure */
216 int arena; /* total size of memory arena */
217 int ordblks; /* number of ordinary memory blocks */
218 int smblks; /* number of small memory blocks */
219 int hblks; /* number of mmapped regions */
220 int hblkhd; /* total space in mmapped regions */
221 int usmblks; /* space used by small memory blocks */
222 int fsmblks; /* space available for small memory blocks */
223 int uordblks; /* space used by ordinary memory blocks */
224 int fordblks; /* space free for ordinary blocks */
225 int keepcost; /* top-most, releasable (via malloc_trim) space */
226 int maxfree; /* (NON-STANDARD EXTENSION) size of largest free block */
229 extern struct mallinfo
239 /*==========================================================================*/
242 # ifdef CYGBLD_ISO_EXIT_HEADER
243 # include CYGBLD_ISO_EXIT_HEADER
246 /* ISO C 7.10.4 - Communication with the environment */
248 /* codes to pass to exit() */
250 /* Successful exit status - must be zero (POSIX 1003.1 8.1) */
251 #define EXIT_SUCCESS 0
252 /* Failing exit status - must be non-zero (POSIX 1003.1 8.1) */
253 #define EXIT_FAILURE 1
259 /* Type of function used by atexit() */
260 typedef void (*__atexit_fn_t)( void );
263 abort( void ) CYGBLD_ATTRIB_NORET;
266 atexit( __atexit_fn_t /* func_to_register */ );
269 exit( int /* status */ ) CYGBLD_ATTRIB_NORET;
271 /* POSIX 1003.1 section 3.2.2 "Terminate a process" */
275 _exit( int /* status */ ) CYGBLD_ATTRIB_NORET;
284 /*==========================================================================*/
286 #if CYGINT_ISO_STDLIB_ENVIRON
287 # ifdef CYGBLD_ISO_STDLIB_ENVIRON_HEADER
288 # include CYGBLD_ISO_STDLIB_ENVIRON_HEADER
291 /* ISO C 7.10.4 - Communication with the environment */
297 #ifndef _POSIX_SOURCE
299 extern char **environ; /* standard definition of environ */
304 getenv( const char * /* name */ );
313 /*==========================================================================*/
315 #if CYGINT_ISO_STDLIB_SYSTEM
316 # ifdef CYGBLD_ISO_STDLIB_SYSTEM_HEADER
317 # include CYGBLD_ISO_STDLIB_SYSTEM_HEADER
320 /* ISO C 7.10.4 - Communication with the environment */
327 system( const char * /* command */ );
336 /*==========================================================================*/
338 #if CYGINT_ISO_BSEARCH
339 # ifdef CYGBLD_ISO_BSEARCH_HEADER
340 # include CYGBLD_ISO_BSEARCH_HEADER
343 /* ISO C 7.10.5 - Searching and sorting utilities */
349 typedef int (*__bsearch_comparison_fn_t)(const void * /* object1 */,
350 const void * /* object2 */);
353 bsearch( const void * /* search_key */, const void * /* first_object */,
354 size_t /* num_objects */, size_t /* object_size */,
355 __bsearch_comparison_fn_t /* comparison_fn */ );
364 /*==========================================================================*/
367 # ifdef CYGBLD_ISO_QSORT_HEADER
368 # include CYGBLD_ISO_QSORT_HEADER
371 /* ISO C 7.10.5 - Searching and sorting utilities */
377 typedef int (*__qsort_comparison_fn_t)(const void * /* object1 */,
378 const void * /* object2 */);
381 qsort( void * /* first_object */, size_t /* num_objects */,
382 size_t /* object_size */, __qsort_comparison_fn_t /* comparison_fn */ );
391 /*======================================================================*/
394 # ifdef CYGBLD_ISO_STDLIB_ABS_HEADER
395 # include CYGBLD_ISO_STDLIB_ABS_HEADER
398 /* TYPE DEFINITIONS */
400 /* ISO C 7.10 and 7.10.6 - Integer Arithmetic Functions */
407 abs( int /* val */ ) __attribute__((__const__));
410 labs( long /* val */ ) __attribute__((__const__));
419 /*======================================================================*/
422 # ifdef CYGBLD_ISO_STDLIB_DIV_HEADER
423 # include CYGBLD_ISO_STDLIB_DIV_HEADER
426 /* ISO C 7.10 and 7.10.6 - Integer Arithmetic Functions */
428 /* return type of the div() function */
431 int quot; /* quotient */
432 int rem; /* remainder */
436 /* return type of the ldiv() function */
439 long quot; /* quotient */
440 long rem; /* remainder */
448 div( int /* numerator */, int /* denominator */ ) __attribute__((__const__));
451 ldiv( long /* numerator */, long /* denominator */ ) __attribute__((__const__));
460 /*==========================================================================*/
462 /* Maximum number of bytes in a multibyte character for the current locale */
464 #ifdef CYGBLD_ISO_STDLIB_MB_CUR_MAX_HEADER
465 # include CYGBLD_ISO_STDLIB_MB_CUR_MAX_HEADER
467 # define MB_CUR_MAX 1
470 #if CYGINT_ISO_STDLIB_MULTIBYTE
471 # ifdef CYGBLD_ISO_STDLIB_MULTIBYTE_HEADER
472 # include CYGBLD_ISO_STDLIB_MULTIBYTE_HEADER
475 /* ISO C 7.10.7 - Multibyte character functions */
483 mblen( const char * /* s */, size_t /* n */ );
486 mbtowc( wchar_t * /* pwc */, const char * /* s */, size_t /* n */ );
489 wctomb( char * /* s */, wchar_t /* wchar */ );
492 mbstowcs( wchar_t * /* pwcs */, const char * /* s */, size_t /* n */ );
495 wcstombs( char * /* s */, const wchar_t * /* pwcs */, size_t /* n */ );
504 /*==========================================================================*/
506 #endif /* CYGONCE_ISO_STDLIB_H multiple inclusion protection */