summaryrefslogtreecommitdiff
path: root/cesar/ecos/packages/isoinfra/current/include/stdlib.h
blob: e17f9200e3bea4a557f980fc33b59ebbdd030dff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
#ifndef CYGONCE_ISO_STDLIB_H
#define CYGONCE_ISO_STDLIB_H
/*========================================================================
//
//      stdlib.h
//
//      ISO standard library functions
//
//========================================================================
//####ECOSGPLCOPYRIGHTBEGIN####
// -------------------------------------------
// This file is part of eCos, the Embedded Configurable Operating System.
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
//
// eCos is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 or (at your option) any later version.
//
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with eCos; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
//
// As a special exception, if other files instantiate templates or use macros
// or inline functions from this file, or you compile this file and link it
// with other works to produce a work based on this file, this file does not
// by itself cause the resulting work to be covered by the GNU General Public
// License. However the source code for this file must still be made available
// in accordance with section (3) of the GNU General Public License.
//
// This exception does not invalidate any other reasons why a work based on
// this file might be covered by the GNU General Public License.
//
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
// at http://sources.redhat.com/ecos/ecos-license/
// -------------------------------------------
//####ECOSGPLCOPYRIGHTEND####
//========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):     jlarmour
// Contributors:  
// Date:          2000-04-14
// Purpose:       This file provides the stdlib functions required by 
//                ISO C and POSIX 1003.1.
// Description:   The real contents of this file get set from the
//                configuration (set by the implementation)
// Usage:         #include <stdlib.h>
//
//####DESCRIPTIONEND####
//
//======================================================================
*/

/* CONFIGURATION */

#include <pkgconf/isoinfra.h>          /* Configuration header */

/* INCLUDES */

/* This is the "standard" way to get NULL, wchar_t and size_t from stddef.h,
 * which is the canonical location of the definitions.
 */
#define __need_NULL
#define __need_size_t
#define __need_wchar_t
#include <stddef.h>

#include <cyg/infra/cyg_type.h>     /* For CYGBLD_ATTRIB_NORET etc. */

/*==========================================================================*/

#if CYGINT_ISO_STDLIB_STRCONV
# ifdef CYGBLD_ISO_STDLIB_STRCONV_HEADER
#  include CYGBLD_ISO_STDLIB_STRCONV_HEADER
# else

/* ISO C 7.10.1 - String conversion functions */

#ifdef __cplusplus
extern "C" {
#endif

extern int
atoi( const char * /* int_str */ );

extern long
atol( const char * /* long_str */ );

extern long
strtol( const char * /* long_str */, char ** /* endptr */,
        int /* base */ );

extern unsigned long
strtoul( const char * /* ulong_str */, char ** /* endptr */,
         int /* base */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 


# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_STDLIB_STRCONV_FLOAT
# ifdef CYGBLD_ISO_STDLIB_STRCONV_FLOAT_HEADER
#  include CYGBLD_ISO_STDLIB_STRCONV_FLOAT_HEADER
# else

/* ISO C 7.10.1 - String conversion functions */

#ifdef __cplusplus
extern "C" {
#endif

extern double
atof( const char * /* double_str */ );

extern double
strtod( const char * /* double_str */, char ** /* endptr */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 


# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_RAND
# ifdef CYGBLD_ISO_RAND_HEADER
#  include CYGBLD_ISO_RAND_HEADER
# else

/* ISO C 7.10.2 - Pseudo-random sequence generation functions */

/* Maximum value returned by rand().  */
#define RAND_MAX  2147483647

#ifdef __cplusplus
extern "C" {
#endif

extern int
rand( void );

extern void
srand( unsigned int /* seed */ );

/* POSIX 1003.1 section 8.3.8 rand_r() */
extern int
rand_r( unsigned int * /* seed */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_MALLOC
# ifdef CYGBLD_ISO_MALLOC_HEADER
#  include CYGBLD_ISO_MALLOC_HEADER
# else

/* ISO C 7.10.3 - Memory management functions */

#ifdef __cplusplus
extern "C" {
#endif

extern void *
calloc( size_t /* num_objects */, size_t /* object_size */ );

extern void
free( void * /* ptr */ );

extern void *
malloc( size_t /* size */ );

extern void *
realloc( void * /* ptr */, size_t /* size */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_MALLINFO
# ifdef CYGBLD_ISO_MALLINFO_HEADER
#  include CYGBLD_ISO_MALLINFO_HEADER
# else

#ifdef __cplusplus
extern "C" {
#endif

/* SVID2/XPG mallinfo structure */

struct mallinfo {
    int arena;    /* total size of memory arena */
    int ordblks;  /* number of ordinary memory blocks */
    int smblks;   /* number of small memory blocks */
    int hblks;    /* number of mmapped regions */
    int hblkhd;   /* total space in mmapped regions */
    int usmblks;  /* space used by small memory blocks */
    int fsmblks;  /* space available for small memory blocks */
    int uordblks; /* space used by ordinary memory blocks */
    int fordblks; /* space free for ordinary blocks */
    int keepcost; /* top-most, releasable (via malloc_trim) space */
    int maxfree;  /* (NON-STANDARD EXTENSION) size of largest free block */
};

extern struct mallinfo
mallinfo( void );

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_EXIT
# ifdef CYGBLD_ISO_EXIT_HEADER
#  include CYGBLD_ISO_EXIT_HEADER
# else

/* ISO C 7.10.4 - Communication with the environment */

/* codes to pass to exit() */

/* Successful exit status - must be zero (POSIX 1003.1 8.1) */
#define EXIT_SUCCESS  0
/* Failing exit status - must be non-zero (POSIX 1003.1 8.1) */
#define EXIT_FAILURE  1

#ifdef __cplusplus
extern "C" {
#endif

/* Type of function used by atexit() */
typedef void (*__atexit_fn_t)( void );

extern void
abort( void ) CYGBLD_ATTRIB_NORET;

extern int
atexit( __atexit_fn_t /* func_to_register */ );

extern void
exit( int /* status */ ) CYGBLD_ATTRIB_NORET;

/* POSIX 1003.1 section 3.2.2 "Terminate a process" */

//@@@ FIXME unistd.h
extern void
_exit( int /* status */ ) CYGBLD_ATTRIB_NORET;

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_STDLIB_ENVIRON
# ifdef CYGBLD_ISO_STDLIB_ENVIRON_HEADER
#  include CYGBLD_ISO_STDLIB_ENVIRON_HEADER
# else

/* ISO C 7.10.4 - Communication with the environment */

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _POSIX_SOURCE

extern char **environ;   /* standard definition of environ */

#endif
    
extern char *
getenv( const char * /* name */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_STDLIB_SYSTEM
# ifdef CYGBLD_ISO_STDLIB_SYSTEM_HEADER
#  include CYGBLD_ISO_STDLIB_SYSTEM_HEADER
# else

/* ISO C 7.10.4 - Communication with the environment */

#ifdef __cplusplus
extern "C" {
#endif

extern int
system( const char * /* command */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_BSEARCH
# ifdef CYGBLD_ISO_BSEARCH_HEADER
#  include CYGBLD_ISO_BSEARCH_HEADER
# else

/* ISO C 7.10.5 - Searching and sorting utilities */

#ifdef __cplusplus
extern "C" {
#endif

typedef int (*__bsearch_comparison_fn_t)(const void * /* object1 */,
                                         const void * /* object2 */);

extern void *
bsearch( const void * /* search_key */, const void * /* first_object */,
         size_t /* num_objects */, size_t /* object_size */,
         __bsearch_comparison_fn_t /* comparison_fn */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

#if CYGINT_ISO_QSORT
# ifdef CYGBLD_ISO_QSORT_HEADER
#  include CYGBLD_ISO_QSORT_HEADER
# else

/* ISO C 7.10.5 - Searching and sorting utilities */

#ifdef __cplusplus
extern "C" {
#endif

typedef int (*__qsort_comparison_fn_t)(const void * /* object1 */,
                                       const void * /* object2 */);

extern void
qsort( void * /* first_object */, size_t /* num_objects */,
       size_t /* object_size */, __qsort_comparison_fn_t /* comparison_fn */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*======================================================================*/

#if CYGINT_ISO_ABS
# ifdef CYGBLD_ISO_STDLIB_ABS_HEADER
#  include CYGBLD_ISO_STDLIB_ABS_HEADER
# else

/* TYPE DEFINITIONS */

/* ISO C 7.10 and 7.10.6 - Integer Arithmetic Functions */

#ifdef __cplusplus
extern "C" {
#endif

extern int
abs( int /* val */ ) __attribute__((__const__));

extern long
labs( long /* val */ ) __attribute__((__const__));

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*======================================================================*/

#if CYGINT_ISO_DIV
# ifdef CYGBLD_ISO_STDLIB_DIV_HEADER
#  include CYGBLD_ISO_STDLIB_DIV_HEADER
# else

/* ISO C 7.10 and 7.10.6 - Integer Arithmetic Functions */

/* return type of the div() function */

typedef struct {
    int quot;      /* quotient  */
    int rem;       /* remainder */
} div_t;


/* return type of the ldiv() function */

typedef struct {
    long quot;     /* quotient  */
    long rem;      /* remainder */
} ldiv_t;

#ifdef __cplusplus
extern "C" {
#endif

extern div_t
div( int /* numerator */, int /* denominator */ ) __attribute__((__const__));

extern ldiv_t
ldiv( long /* numerator */, long /* denominator */ ) __attribute__((__const__));

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

/* Maximum number of bytes in a multibyte character for the current locale */

#ifdef CYGBLD_ISO_STDLIB_MB_CUR_MAX_HEADER
# include CYGBLD_ISO_STDLIB_MB_CUR_MAX_HEADER
#else
# define MB_CUR_MAX 1
#endif

#if CYGINT_ISO_STDLIB_MULTIBYTE
# ifdef CYGBLD_ISO_STDLIB_MULTIBYTE_HEADER
#  include CYGBLD_ISO_STDLIB_MULTIBYTE_HEADER
# else

/* ISO C 7.10.7 - Multibyte character functions */


#ifdef __cplusplus
extern "C" {
#endif

extern int
mblen( const char * /* s */, size_t /* n */ );

extern int
mbtowc( wchar_t * /* pwc */, const char * /* s */, size_t /* n */ );

extern int
wctomb( char * /* s */, wchar_t /* wchar */ );

extern size_t
mbstowcs( wchar_t * /* pwcs */, const char * /* s */, size_t /* n */ );

extern size_t
wcstombs( char * /* s */, const wchar_t * /* pwcs */, size_t /* n */ );

#ifdef __cplusplus
} /* extern "C" */
#endif 

# endif
#endif

/*==========================================================================*/

#endif /* CYGONCE_ISO_STDLIB_H multiple inclusion protection */

/* EOF stdlib.h */