comparison packages/language/c/libc/current/include/stdlib.h @ 0:3111d98ba7b3 ecos-v1_1-release

Initial commit of eCos version 1.1
author jlarmour
date Tue, 11 May 1999 11:16:07 +0000
parents
children 443894e2e912
comparison
equal deleted inserted replaced
-1:000000000000 0:3111d98ba7b3
1 #ifndef CYGONCE_LIBC_STDLIB_H
2 #define CYGONCE_LIBC_STDLIB_H
3 //========================================================================
4 //
5 // stdlib.h
6 //
7 // ISO C standard utility functions (ISO C standard section 7.10)
8 //
9 //========================================================================
10 //####COPYRIGHTBEGIN####
11 //
12 // -------------------------------------------
13 // The contents of this file are subject to the Cygnus eCos Public License
14 // Version 1.0 (the "License"); you may not use this file except in
15 // compliance with the License. You may obtain a copy of the License at
16 // http://sourceware.cygnus.com/ecos
17 //
18 // Software distributed under the License is distributed on an "AS IS"
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
20 // License for the specific language governing rights and limitations under
21 // the License.
22 //
23 // The Original Code is eCos - Embedded Cygnus Operating System, released
24 // September 30, 1998.
25 //
26 // The Initial Developer of the Original Code is Cygnus. Portions created
27 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //========================================================================
32 //#####DESCRIPTIONBEGIN####
33 //
34 // Author(s): jlarmour
35 // Contributors: jlarmour@cygnus.co.uk
36 // Date: 1998-02-13
37 // Purpose:
38 // Description:
39 // Usage: #include <stdlib.h>
40 //
41 //####DESCRIPTIONEND####
42 //
43 //========================================================================
44
45 // CONFIGURATION
46
47 #include <pkgconf/libc.h> // Configuration header
48
49 // Include the C library?
50 #ifdef CYGPKG_LIBC
51
52 // INCLUDES
53
54 #include <cyg/infra/cyg_type.h> // Common type definitions and support
55 #include <stddef.h> // NULL, wchar_t and size_t from compiler
56 #include <limits.h> // for INT_MAX definition used below
57
58 // CONSTANTS
59
60 // as described in ANSI para 7.10
61
62 // codes to pass to exit()
63
64 #define EXIT_SUCCESS 0 // Successful exit status
65 #define EXIT_FAILURE 1 // Failing exit status
66
67 // Maximum value returned by rand()
68
69 #define RAND_MAX INT_MAX
70
71
72 // Maximum number of bytes in a multibyte character for the current locale
73
74 #define MB_CUR_MAX 1
75
76
77 // TYPE DEFINITIONS
78
79 // as described in ANSI para 7.10
80
81 // return type of the div() function
82
83 typedef struct {
84 int quot; // quotient
85 int rem; // remainder
86 } div_t;
87
88
89 // return type of the ldiv() function
90
91 typedef struct {
92 long quot; // quotient
93 long rem; // remainder
94 } ldiv_t;
95
96 // Unofficial type of comparison function used by both bsearch() and
97 // qsort()
98
99 typedef int (*Cyg_comparison_fn_t)(const void * /* object1 */,
100 const void * /* object2 */);
101
102 // Similarly, type of function used by atexit()
103 typedef void (*Cyg_atexit_fn_t)( void );
104
105
106 // FUNCTION PROTOTYPES
107
108 //========================================================================
109
110 // 7.10.1 String conversion functions
111
112 externC double
113 atof( const char * /* double_str */ );
114
115 externC int
116 atoi( const char * /* int_str */ );
117
118 externC long
119 atol( const char * /* long_str */ );
120
121 externC double
122 strtod( const char * /* double_str */, char ** /* endptr */ );
123
124 externC long
125 strtol( const char * /* long_str */, char ** /* endptr */,
126 int /* base */ );
127
128 externC unsigned long
129 strtoul( const char * /* ulong_str */, char ** /* endptr */,
130 int /* base */ );
131
132 //========================================================================
133
134 // 7.10.2 Pseudo-random sequence generation functions
135
136 externC int
137 rand( void );
138
139 externC void
140 srand( unsigned int /* seed */ );
141
142 // POSIX 1003.1 section 8.3.8 rand_r()
143 externC int
144 rand_r( unsigned int * /* seed */ );
145
146 //========================================================================
147
148 // 7.10.3 Memory management functions
149
150 #ifdef CYGPKG_LIBC_MALLOC
151
152 externC void *
153 calloc( size_t /* num_objects */, size_t /* object_size */ );
154
155 externC void
156 free( void * /* ptr */ );
157
158 externC void *
159 malloc( size_t /* size */ );
160
161 externC void *
162 realloc( void * /* ptr */, size_t /* size */ );
163
164 #endif // ifdef CYGPKG_LIBC_MALLOC
165
166 //========================================================================
167
168 // 7.10.4 Communication with the environment
169
170 externC void
171 abort( void ) CYGPRI_LIBC_NORETURN;
172
173 externC int
174 atexit( Cyg_atexit_fn_t /* func_to_register */ );
175
176 externC void
177 exit( int /* status */ ) CYGPRI_LIBC_NORETURN;
178
179 /* POSIX 1003.1 section 3.2.2 "Terminate a process" */
180
181 externC void
182 _exit( int /* status */ ) CYGPRI_LIBC_NORETURN;
183
184 externC char *
185 getenv( const char * /* name */ );
186
187
188 //========================================================================
189
190 // 7.10.5 Searching and sorting utilities
191
192 externC void *
193 bsearch( const void * /* search_key */, const void * /* first_object */,
194 size_t /* num_objects */, size_t /* object_size */,
195 Cyg_comparison_fn_t /* comparison_fn */ );
196
197 externC void
198 qsort( void * /* first_object */, size_t /* num_objects */,
199 size_t /* object_size */, Cyg_comparison_fn_t /* comparison_fn */ );
200
201
202 //========================================================================
203
204 // 7.10.6 Integer arithmetic functions
205
206 externC int
207 abs( int /* val */ );
208
209 externC div_t
210 div( int /* numerator */, int /* denominator */ );
211
212 externC long
213 labs( long /* val */ );
214
215 externC ldiv_t
216 ldiv( long /* numerator */, long /* denominator */ );
217
218 //========================================================================
219
220 // INLINE FUNCTIONS
221
222 #ifdef CYGIMP_LIBC_STDLIB_INLINES
223 #include <stdlib.inl>
224 #endif
225
226 #endif // ifdef CYGPKG_LIBC
227
228 #endif // CYGONCE_LIBC_STDLIB_H multiple inclusion protection
229
230 // EOF stdlib.h